AgileData #21 - The magic of serverless
3 Nov 2020 · 25 min
Shane Gibson and Nigel Vining break down what serverless actually means: you pay for what you use instead of owning and patching the OS. They walk through Google Cloud products like BigQuery and Cloud Functions, then land on the core principle: serverless first, but not serverless over everything.
Chapters
Foreign.
Welcome to the Agile Data Podcast, where Shane and Nigel discuss the techniques they use to bring an agile way of working to the data world in a simply magical way.
Welcome to the Agile Data Podcast. I'm Shane Gibson.
And I'm Nigel Vining.
And today, Nigel and I thought we'd have a bit of a chat again. Another kind of engineering focused chat, but this time we want to talk about this thing called serverless, which is something that we use a lot on the cloud platform that we leverage. For me, it's a really, really funny word. In fact, a number of years ago, I was very disparaging of the term serverless because there actually is servers involved, right, Nigel?
Yeah, it is a misnomer. There's a server under the covers. It's just what the definition of serverless actually means to you, I guess.
Yeah. So why don't we start off with trying to define how we would determine if something was serverless or not.
Sure. So my definition of how we use it is you don't own the server, you don't have to manage the server. You basically use that server on a second by second or minute by minute basis and you pay for that fraction of the time something is actually executing. Up 99% of the time you're not doing anything with that server. So we call it serverless.
Yeah.
So for me, I like that definition. I like the definition of when I ask it to do something, I get charged, and when I don't ask it to do something, I don't get judged. So for me, that is one of the tenants of a serverless piece of technology and one of the benefits it gives me.
Yeah, I agree.
I like it for the simplicity, that you don't have to worry about all the overhead that goes with a server in the traditional sense of the word, which is data centers, networking, patching, upgrading, basically all the downsides of running your own server, you don't have any of that with serverless. You just ask it to do something, it does it, it always works and then it stops.
So if we compare, you know, something that's serverless versus something that's based on a container for a container. I don't own the server, I don't own the network, I don't own the disk. Effectively, I don't own the infrastructure. But in my definition, it's not serverless because I have to turn it on and I have to pay while it's running, whether I'm actually using it or not. It's sitting there charging me. Right?
Yes. Some of the products on most cloud platforms are badged as serverless, but you are paying a hourly rate, effectively, because that server is always available to run your container. It never goes to zero, is what we'd say under the covers, there's always one of it running.
So it's a virtual server then, right?
Yeah, yeah, that's a good definition.
Okay, so why don't we run through all the moving parts we use and then try and have an idea of whether we think they're serverless and what the value of them is. So let's start with the big one, BigQuery, where we store a lot of really cool data. So what do you reckon? Serverless, virtualized Server, physical server?
BigQuery is an interesting one because there's two things going on there. There's the compute resource, which I'm going to say is effectively serverless, because if it's not doing any work, you're not being charged. But behind that you've got your stored data, which is being stored, and you are being charged while it's been stored but not being used. BigQuery is a bit of a hybrid.
And that's when we use a charging mechanism against it. Right. If I use a metric of how am I billed to define whether it's serverless or a virtual server, then BigQuery really fits in the middle.
Yeah, it's got a split cost you're paying to store over the long term. Obviously, as we talked about a couple of weeks ago, if you're not accessing your data all the time, it goes off to lower tiers of storage and it's cheaper. But if you're not running queries, BigQuery is not charging you anything.
So one of the other ways to look at it is, with a virtual server, I've got to install and maintain the software. Right? I mean, I may use some form of template or image or some magical provisioning thing that grabs it off a marketplace and that stuff, but really what's held within that virtual container is mine. I control when it's upgraded and when it's not.
Not.
I can control how it's configured at any level and how it's not. I have access to the operating system nine times out of ten.
Right.
Whereas if we look at BigQuery, we have none of that.
Right.
We don't control when new features are added or when it's patched. We don't have any access to the underlying operating system or the infrastructure that it runs on.
You know, we don't go to a marketplace. We Just tick a box or use code in our case to say we want to access one. So is that kind of the second way we can look at it is one, how we charged and B what we control.
Yep, that's a good one. That naturally flows on to. It's got me thinking about.
Cloud functions which we make use of, and that's exactly that case. We pay per second of compute time, but we don't control the, I guess the architecture os. We choose what type of architecture we want to run our code on up front. For example, we'll say I want to run a Python cloud function and all I provide is literally the code I need to run. Python is pre installed, it's patched, it's good to go. We don't control that. We've just asked for a Python environment and we throw stuff at it and we get charged per second to run it.
And so if we look under the covers of cloud functions, because we spent quite a bit of time looking under the covers as much as we can with cloud functions, really. It operates differently to BigQuery though, right. So the perception I get is BigQuery has a whole lot of infrastructure just sitting there that everybody kind of hits.
And when we want to run something that runs it for us, allocates us some resources off that big cluster Y thing. But when we look at cloud functions, we can kind of see that they're stopping and starting virtual servers on a regular basis every time we want to run something. So architecturally, they're running one's more of a clustered shared environment and the other one's more of on demand virtual server environment. But from our point of view, we pay for what we use and we don't control any of the underlying infrastructure or operating system for even those services, right?
Yeah, which is actually nice because effectively there's nothing to worry about. We throw coded it, it runs. If we throw two bits of code at it, it starts two instances and runs them. If we throw 100, it still does the same behavior. It is a consistent behavior. You can run one or 100 cloud functions simultaneously. You do not have to worry about it.
I'm going to just say it just works.
Let's look at the other end of the extreme. For us.
We do documentation as code. We, we write small bits of code that is effectively our documentation. Whenever I check it into our repo, some magic happens and our documentation site gets rebuilt with that latest version of all that documentation and code. But that's not a serverless architecture that we're leveraging for that puppy is it.
Sort of. It's midway, I guess. The serverless architecture is a continuum from the small ones that we pay per second and we have no control over to the ones where you talked about containers and VMs before. So for our documentation, we have a image which contains our. I'm just going to call it our documentation engine, which is the Sphinx open Source library. We have an image of Sphinx that's customized to how we want to build our documentation. And effectively, when we do a build, it mounts that container, runs it for a period of time while it builds our documentation, then it shuts it down. So it is serverless in some sense. The word. But it's different in that we're effectively mounting our own custom image. So we get to choose what's installed on that image and what's running, but we're still just paying for the amount of time that that image is mounted and running. And then it basically shut down again and it's nothing. But it's upper tier from a cloud function.
But it's not a full, you know, constantly running server. We mount it, we use it, we drop the image, and it's done.
Okay, but my understanding is that serverless ish behavior is something you've engineered, right?
I guess so.
We needed a level of customization that didn't come with a cloud function because we needed to customize the OS effectively and install some additional products that weren't available in a cloud function. So we built our own virtual image that we run for a period of time and then shut down. It happens automatically for us. It's just another level of serverless. Serverless type behavior.
Yeah. So it's not a service or a serverless feature we get from Google. What you're doing is leveraging some of the Google services to provide a capability that behaves in a serverless pattern. You copied the pattern, but you had to build it. If I go back to my two checks, do we pay for when it's not running? No, because you define use the pattern that says when it's not running, turn it off.
Do we control the operating system and that container itself, and are we responsible for patching and maintaining that container? And the answer is yes. We get one of the benefits of a serverless pattern and the other one we wear, the cost and effort of maintaining that.
That's exactly right. If we want to update the documentation builder, store more features, or patch it to a newer version, we basically have to start up that image, update it, and then rep assist it so we can Use it next time. It's called upon.
Cool. So what else we got in the technology stack that we can have a look at? What about the cloud repo where we store our magic code?
Yeah, I was going to say the next on top of the cloud repo, we make use of the cloud build functionality, which I guess is a form of serverless products. What we do then is by using commit triggers on our repos when new code is committed into specific repositories. What we basically says, if the master branch of, say, I don't know, documentation is updated, then I want you to use cloud build, which is a serverless feature, to run a whole lot of steps for us, deploy some code, check it, and then shut down again. So cloud builds a little bit special because we effectively can perform a whole set of instructions. So it might say, get the latest code that's been committed.
Do this to it, do that to it, copy it here, copy it there, and then send me a message to saying, you've done that. So again, cloud build is charging us per second that it's running to perform our instructions. So we typically use it to pull the code out of the repo, do some functions on it, and then possibly copy the output into a cloud storage bucket and then shut itself down again. Cool.
So do you tell cloud build to start and stop or does it just wait for you to call it and then when it's finished its job, it shuts itself down?
So it's triggered by something happening. In this case a commit to a repository. A user can invoke it directly off the command line. I can say, run this cloud build script while we're developing it. It works in exactly the same way. Think of it as a recipe. It's got a list of instructions doing it when it started cloud build, reads through the list, does all the instructions and then shuts down.
So from a serverless costing point of view, Google Cloud takes care of that serverless behavior for us.
That is exactly right. It's running on our server in the background. It's not ours. We don't maintain it. It just runs a set of instructions. Cool.
That's the second question is we don't maintain that operating system, we don't patch it. It's a true serverless offering from Google rather than something where you've applied the serverless pattern.
Exactly. Cool.
Cloud repo, same thing. We just check code in.
And when it needs to receive that request, it does something and receives it. And if we don't talk to it for a while, it doesn't care and never do we. Well, we care because we're not checking our code in, which means we're either not working or we're doing bad, bad things from a Darts point of view. But as a serverless component, it doesn't care.
Yeah, exactly.
Cool. So what about the code that we use to go and hit some click data from some of the data factories? So let's say when we go and hit Shopify and grab the data out of that puppy.
Which of the patterns are we using?
For that one, we actually use.
Cloud build and a container for that one we use a container. We use a container because the container has the particular.
Software installed on it that we use to talk to those APIs. So we've installed that library on the container and when required, we effectively run that container and then we shut it down again.
So we've applied a serverless pattern.
Yes.
To something that's more of a container model. Right. Because we still control the operating system, we control that, that container image, we control those things.
That's correct. Because we've installed a number of pieces of open source software in that container that have the libraries for talking to the APIs in question.
So we maintain that we just use the serverless pattern to run that container for us and get charged per second while it's running and then shut it down again.
So why wouldn't we just use the serverless.
Pac man out of Google Cloud instead of having to apply our own.
Pattern for this one.
We needed to install the software we wanted to run somewhere. So our options are we can have something that's literally a real server that's running 247 and we're paying for it the whole time, but we only want to execute those libraries once a day. Maybe.
I think the other thing was when we did it from memory, or when you did it from memory.
The open source software we're using required certain permissions or behavior from the server or container it was running in. When we tried to deploy it into the serverless services.
It effectively didn't run properly. There were things that relied on that serverless capability didn't allow us to do. Because we don't own the operating system, we don't own the underlying disk, we don't own a whole lot of moving parts that actually that particular piece of software assumed you had access to and was designed to actually leverage. And therefore.
Computer said no. Right.
Actually, you've just jogged my memory. At the time when we started this journey, the cloud functions that we would have used for Everything had a timeout of three minutes on them, which is why we got bumped up the additional serverless ones. Because at the time the smallest tier of serverless was 3 minutes, the next tier was 9 minutes, and then the next tier up was as long as you like. Three minutes wasn't long enough to basically set up the environment, run the APIs to pull data and bring it all down within that three minute period. Which is why we actually had to deploy a container which didn't have a time restraint. But since Google was very helpfully three times in the last 18 months bumped up those time limits, Cloud functions can actually run for nine minutes now from memory, which is potentially long enough to do a data extract using an API.
Yeah, so there is still a risk though when you use a serverless feature that there will be some type of access or capability that you would normally be able to leverage on a container on a physical machine or a virtual server that that serverless thing doesn't allow you to do. Right. And so therefore you have to regress back to applying some form of serverless pattern to that container based pattern.
And those restrictions are probably likely around cpu, memory and disk. Because using serverless, the true serverless, you're effectively using a.
A preset environment. It's got say two CPUs, it's got X Gig of memory, and you've got access to X Gig of temp storage. I'm going to say. So if your requirements are for something that's very memory intensive and I'm just going to say, for example, cloud function may only give you a four gig of memory, but really you're going to need twice that much because you're going to do something chunky.
That'S not going to work for you. Or if you need to physically store a whole lot of data on a local disk, again that's potentially not going to work for you, which is where you go to your own pre built image. Because you can say, I need a container that's going to have access to plenty of disk or plenty of memory. And that might be a guiding choice.
So really it's quite confusing, right, because you can get something out of the box that's serverless, you can get something out of the box that behaves serverless because you only pay for what you use and you don't manage the operating system. But you was talking about number of CPUs and amount of memory, which to me makes me think of a server. And then you can take virtual containers and make them behave using a serverless Pattern where they only run when you need them to run, so you only pay that way and you're effectively using some form of template to manage the operating system. So while you're still having the pain of managing it, it's kind of magical when you use it.
So really there's a lot of things to think about when you talk about is it serverless or is it not?
Yeah, it becomes technical after a while and I think what makes it more challenging is there's multiple products on a spectrum and they all slightly overlap. So the smallest, you know, offering may actually cover all use cases. Well, up until the middle offering. And, you know, the middle offering may do all your small use cases and then into your large UK use cases. So it's no. There's no hard and fast rule that says this is my use case. So I automatically use the serverless function because to be honest, all of them will, all of them might satisfy that. Then you've got to make a second choice around how fast will it be when it runs. So I might choose an architecture that's going to be quicker or, you know, more performant with a less latency when it starts up and shuts down. Because some of the serverless comes with a small overhead because you're effectively, you've made a request, it's now got effectively start itself off to deliver your service and shut itself down. It may only be a second or a fraction of second or two seconds. That may be an important consideration for you.
So I think, you know, for us it shows the value of our guiding principles from an architecture point of view. And by that I mean, you know, at the beginning, when we need to do something new, we will always look for a serverless component that enables us to only pay when it runs and not have to wear the cost and effort of maintaining an operating system or patching or managing that container. And if we find one of those and it meets our needs for now, that's what we use. Right. And we know that we can always refactor that, that service, that Pac man later on to something that we have more control over, but takes more effort and therefore more costs on our side to maintain. So the guiding principle of serverless first but not serverless over everything is really, really important.
Right, Agreed. Yeah, we always look for the serverless, the smallest serverless option and then we just go up a level if it doesn't quite do it, and up another level if we have to. But serverless first principle. Yep.
And then always ready to refactor because we know that over time Google, in our cases, Google Cloud's adding more and more serverless features or removing some of the barriers of the serverless stuff that we were using to means that we can actually refactor stuff where we've gone for more control for a reason, back to being able to leverage the value of that service.
Absolutely.
I struggle with the word serverless service. I know why. I think it's an alliteration.
Isn't it a misnomer?
Yeah.
It'S just a bad sentence when I say it.
Or a couple of words. So the future is serverless, I think, is my takeaway.
Well, actually I think.
The future is biometric computing. So the real question then is when we move from silicon to organism based compute, is that a server or is it a host? That'll be really interesting, interesting distinction when that comes out in whatever years it is. But I think for now, I think we've kind of talked about serverless and we'll probably put that one in the can.
Done. Thanks, Shane.
And that Data Magicians was another agile data podcast from All Module and Shape. If you want to learn more about how you can apply agile ways of working to your data, head over to agiledata IO.
More from Shagility


Listen now | Recording of AURA - Tim Frazer & Shane Gibson on 2nd September 2026








