Not everything is a function
I’d like to rant about Serverless. Parts of the serverless idea are fantastic. Parts are ridiculous. Let me tell you why.
Fantastic parts about serverless:
- I only have to worry about my code. No patching, no operating systems, no containers, no orchestration, no how-do-I-scale-this?, no ssh-ing in to fix something: just code. This is brilliant.
- If I want to, I can push small functions and let other people invoke them. These can be billed for on an as-needed basis as the platform scales those functions up and down. Again I can just focus on code and let the platform worry about scaling and billing. Great.
Ridiculous parts about serverless:
- Let’s rewrite everything as functions and then use the serverless system to orchestrate everything together. This is insane. Programming languages exist for a reason and they’re really really good at expressing these sorts of things. They’re also easy to test and reason about and iterate on and develop with others.
- Let’s rewrite our whole app as functions even though that will make it harder to understand and reason about because then all of it will be Web Scale. It won’t. The only parts of your app that need to be independently scalable small functions are the parts you want lots of people to be able to consume and be billed for independently, and the parts that are disproportionately called by other parts of the system or other systems. You don’t need to rewrite your whole app, you need at most a few micro-service-like functions. You can probably extract these later.
- You probably don’t need to split out most things as independent functions. Most people’s apps will run fine as a monolith on a single instance somewhere. If they suddenly need to scale you can run two instances of the app and for most apps most of the time: you’re done. Nothing new to learn, nothing new to reason about. You’re welcome. Is this all apps? nope. But is it most?.. Are most apps really suited to serverless? Is every problem a nail just because you have a great hammer?
Did you notice something about the ridiculous parts? They’re all just examples of people taking a (great) hammer and deciding to use it on all sorts of things that just aren’t nails.
Serverless is a great hammer for a particular, small subset of things we develop. But if what you’re writing is a simple web app trying to make it serverless (unless you just mean you want to push the whole thing as code to a platform that doesn’t make you worry about servers or containers — in which case I agree, good plan) is just buying pain and complication. Most folks don’t need it. The folks that need it need it for a few functions and services that they can extract over time.
What we do need is systems that give us the benefit of just caring about code but that don’t make us try to split everything in to mini-functions before there’s any real benefit to that. Let me split out a function here and there, but don’t let’s pretend that that’s the primary abstraction I should use.
I want to be serverless, and I want to be containerless and I want to be orchestratorless.. I don’t want to be app-less.
In five years, I hope I’ll be able to just push my web app to the cloud and have it scale. If it has a few functions that are worth scaling/consuming independently it’d be great if I can easily extract those and make them available to multiple apps. But the main abstraction is code, not functions. Let me write apps.
