Meta's serverless platform processing trillions of function calls a day (2023)
read.engineerscodex.com
read.engineerscodex.com
I'd love to know people's (objective if possible) thoughts, experiences and opinions on such an approach.
We are finding that this is a much easier operational model in a B2B/SaaS consulting setting wherein our customers (banks & credit unions) must retain legal ownership over their data. Setting up a VM/container circus per customer and expecting them to keep it healthy is not something we are prepared to continue beyond client #5 or so. There is zero reality wherein we could maintain some kind of multi-tenant system.
After targeting this stack seriously for about a year, I am having a hard time coming up with a reason I wouldn't use it for everything. Not having to think about VMs and weird crusty infra management code has freed up an incredible amount of bandwidth for our development team.
When it comes to serverful, you have to provision (or perhaps "over-provision") resources ahead of time. If you can estimate your CPU/memory/disk/network needs beforehand, you can just as well rent an appropriately powerful, "serverful" server to achieve your goal. If you assume (figure out) a particular desired number of API requests per second that you need to handle, analyze and benchmark a particular set of hardware resources that can likely handle such throughput and also calculate a per-request -based price of the same throughput with a serverless provider, you will probably find that serverless is at least twice as expensive as serverful.
I really like the model of functions decoupled through events. Big fan of that. It's very flexible and iterative. Keep that as your focus and it's great. Be careful of duplicating config, look for ways to compose/reuse (duh, but definitely a lesson learnt) and same with CI, structure your project so it can use something off-the-shelf like serverless-compose. Definitely monorepo/monolith it, I'd be losing my mind with 100-150 repos/"microservices" with a team this size. If starting now I'd maybe look at SST framework[0] because redeploying every change during development gets old fast
I couldn't go back to any other way to be honest, for cloud-heavy backends at least. By far the most productive I've ever been
Definitely has its warts though, it's not all roses.
[0] http://sst.dev
I'd definitely be careful in my own decision in trying out SST so I'd recommend doing the same for anyone who is taking my suggestion seriously
I think it was generally convenient as being very low maintenance. The only availability canary alarms are when the underlying services go down, which is almost never.
Debugging and running locally are the weak points. Eliminating an entire class of things to think about (container health, scale in and out, and so on) is very nice. Since it’s a control plane, tps and costs were low.
As far as I know, that scenario is not in the decision tree for when to go with function-as-a-service offerings. FaaS is for things like glue code for event handlers, low-traffic services like API Gateway/NLB calling Lambdas, and expensive tasks that can be offloaded from a worker thread to a Lambda.
When traffic going into a FaaS-based service starts to go up, the cost of running Lambdas stops being competitive and you're better off just having a dedicated service handle the work.
Nevertheless, the main selling point of FaaS is not performance, throughput, or even developer convenience. The main selling point is hardware utilization. If your dev teams deploy FaaS stuff instead of dedicated services, the company doesn't need to provision anything to get them to run. The functions are just deployed in the sea of FaaS things they have been running, and they can live with high hardware utilization just fine.
So that's good to know. Do you have any references, in terms of further reading material, for the cross over point for when it's stops being competitive? I highly doubt $cloud_provider is going to give you such a analysis for obvious financial reasons.
I'm afraid I don't. The most objective cutoff point I can come up with is based purely on cost. Meaning, cloud providers like AWS might offer a free tier for API Gateway and Lambdas which makes them really competitive vs running a container or launching a VM when traffic is low. However, once your traffic starts to go beyond the free tier (IIRC per month it's 1million requests for API gateway and 400,000 GB/s for lambdas) then operational costs starts to overtake the cost of running a traditional service. How many requests your service handles on all endpoints and how much computational budget each lambda spends is a trait of your own service, and reflects low-level decision such as how you designed your API and what runtime did you chose for your lambdas. Basically this boils down to the FaaS solution eventually leading the cloud provider to charge you per each request, while your traditional service running either in a container or on a VM having a fixed cost. After some math you'll arrive at s traffic volume that can represent the tipping point between FaaS and traditional services.
Personally, my subjective cutoff point is when FaaS costs about 30% of traditional setvices. Once your FaaS cost starts to grow, you're tempted to micro-optimize your API and your service to try to keep it's running cost justifiably low. That's when you're starting to be tempted to put together a sucky service as a cost tradeoff. When that time comes, it's better to bite the bullet and just migrate away from FaaS.
It has also been built by contractors who have no incentives to make it run locally or be easy to manage in production, but that isn't specific to step functions, and more due to poor leadership.
To be fair AWS does provide a "CDK" which lets you write Python code that gets converted into their JSON DSL -- or something along those lines. But I haven't used that, only direct JSON DSL "code" to write step functions.
It fetches function calls from DurableQs, consolidates them into FuncBuffers (ordered by importance, then execution deadline),
Since that is a classic source of priority inversions (which is that 'important' messages overwhelm the system resulting in less important messages missing their execution deadline) If there is someone reading this that knows this system can you tell me if they queue ranking is actually rank = f(priority, deadline) ? Where things close to their deadline can out rank high priority things?
The other question that I had but didn't get from skimming was how they do data management. Do the functions carry around all their data? Is any of that data part of a state machine? (which is to say mutating that data by the function results in a new 'state' which would affect other functions using that data)
Edit: Read the OG version here.
https://soteris.github.io/publication/sahraei-2023-xfaas/sah...
I'm so excited for the webassembly future, where a huge number of shared modules can be left in memory, sandboxed, and when my function calls such a module, it's already resident & loaded.
Now, those members of our fair technological coven, of a certain age (who are sadly dwindling in number) will certainly recognise sending off a program to be run by a big magic massive machine, and waiting for results later on. Thats batch computing.
Now the key advantage of batch computing here, as also laid out by the paper is that you can group stuff together to cut out VM warmup time.
BUT it also means that because you have the luxury of waiting, you can use spare CPU cycles when they are free. As with everything big sites have burst of traffic, so to handle that, you have lots of spare CPU cycles waiting around.
if you clearly telegraph that your function is liable to be delayed, killed or re-run, then there are still lots of useful work that can be done without costing you more in capacity.
Its a strongly under utilised pattern in modern computing.
this form of serverless is very much batch jobs with some modern bits sprinkled in.
perhaps they should have called it serverless batch, or Batch-as-a-service, async-serverless or serverless-futures.
Of course ultimately the code runs on a server, but it's not a server that the customer has to buy, rent, maintain, or otherwise think about.
For us this is by far the biggest factor. Innovation tokens are the most expensive thing there is.
Basically it's "serverless" because you the developer are not doing anything with servers. You're not writing one, maintaining one, or managing the infrastructure to run one. You drop off a blob of logic to the cloud provider and they handle everything else for you, and you pay on demand.
Functions-as-a-Service (FaaS) is another name for the same idea but less catchy
CGI-Bin
Mainframes
which were deeply out of fashion at the time.