Why? What’s the downside? Are you taking the benefits into account in your calculus? This sort of general, input-free recommendation is junior level thinking at best.
> I am fairly confident I could support more capacity with a single t3a.nano instance.
It depends on what resources those connections are using (memory, CPU, I/O, network). What actual work is being done?
My guess is that the IaC is the special sauce that's missing; you do need to go all in with some IaC solution to make using Lambda easy, but it doesn't take a lot of it to make it slick.
Cost/compute is obviously strictly worse for FaaS, but most web workloads don't _really_ need to be optimal.
No adapters needed; just write a web API and ship it. Public URL gets assigned and its ready for use. Code works locally with no special adapters, emulators, or tooling needed. Need to support another cloud plat tomorrow? Ship the same container. Moving it to self-managed K8s? Same container.
AWS has Fargate which does the same thing if you are building containers.
https://sliplane.io/blog/comparing-prices-aws-fargate-vs-azu...
That particular use case can go from hardly any traffic at all to a hurricane of traffic during something like, well, a hurricane.
For consistent processing loads, I think I could save money by just running on dedicated EC2 instances, but you cannot beat the instant scale of Lambdas.
Shameless plug: https://play.google.com/store/apps/details?id=app.radarlove....
Specify the maximum number of allowed instances and maximum concurrency per instance. Optionally configure more targeted scale rules. It will scale it from 0 - n as needed.
[0] https://docs.cloud.google.com/run/docs/about-instance-autosc...
[1] https://learn.microsoft.com/en-us/azure/container-apps/scale...
Indeed if you configured each instance as a single threaded handler, you will not have fun.
> In your scenario, every request is hitting either an overloaded instance,
Why would this be the case? Cloud Run containers and an app runtime like .NET, Java, Go, Rust can inherently be multi-threaded, multi-connection. It can handle up to 1000 concurrent connections per container using just threads and async (assuming sufficient size). Any workload that requires hitting the DB or backend service (S3, etc) is going to I/O bound and sitting in a future most of the time anyways.The container instances auto-scale by default to a configured n (0 - n) with the option to define specific scale points. If I'm sensitive to high bursts, this can be a matter of scaling at 50% capacity and a warm instance is available while the application still has headway.
Cases where this falls apart: DDoS in which case, I argue that 1) it is better in any case that it falls apart rather than absorbing that type of traffic spike, 2) such traffic is better filtered upstream in any case in an API Gateway + WAF.
I have worked with both types of solutions for different use cases (was invited presenter at Azure Serverless Conf[0]), but my take nowadays is that serverless containers are almost always a better approach since it provides much more flexibility.
[0] https://learn.microsoft.com/en-us/shows/azure-serverless-con...
At which point we're paying double just to work around cold start latency, which was the original point.
So if you're at 50% capacity with lots of idle time, it can scale to 0.
Scale to 0 doesn't mean "cold". One easy way to keep both Cloud Run and Container Apps "warm" but functionally scaled to 0 for costs is to just ping it every few minutes with Cloud Scheduler set up on a cron pointing to a health endpoint.
This diagram helps visualize: https://www.gstatic.com/bricks/image/5eb3c8e9-6159-4e2f-ba98... (gray bar at the top shows when the instance is started and when it ends; blue bars show actual request, and green bars show the billing)
If there's a 10s gap between requests, you are not billed for the 10s gap, but it is still effectively hot; instance does not stop. Request that comes back in 10s later does not have a startup penalty because the instance is still up.
How do you leverage this to build a high throughput system with no cold starts? Just prime it with a short single request (e.g. `/health`) before instance is stopped.
So you might have to wait for 10s or more to have a new lambda instance spawning up and replying to your requests. And you might have to have your function finish in 15 minutes, deals with the strange concurrency and scaling rules lambda is based on.
You make it sound like these cases are rare, not sure what kind of work you do but there are markets of all sizes in many different use cases out there.
I feel like what you wanted to say was "I haven't found a need for them" as opposed to "Stay away from it"
Maybe you're trying to say something else we don't know because we don't have your backstory either, did folks at your work tried pushing it for scenarios in which they became a problem? Share that instead as it brings a lot more value to the readers, otherwise it sounds like you are trying to go for a weird flex.
The Google paper Towards Modern Development of Cloud Applications[0] does a great job explaining why.
TL;DR the case they make against micro-services architectures (which Lambda encourages):
1. It hurts performance
2. It hurts correctness
3. It is hard to manage
4. It freezes APIs
5. It slows down application development
For even a moderately complex system, spreading logic out over multiple discrete runtimes doesn't make sense; instantly run into each of the 5 points. The only times I've found functions useful is truly single-point behavior where we were running some logic connected to CloudFront on each request for some header parsing.It is certainly possible to write a monolith in Lambda as well, but then that would be bad architecture and a bad fit and I suppose why they are now introducing this new model that is more like GCP Cloud Run or Azure Container Apps.
[0] https://sigops.org/s/conferences/hotos/2023/papers/ghemawat....
You've taken it in a rather odd direction with the request for a framing more palatable to you.
All that said, there are times I regret my lambda decision and would prefer just a EC2 host even if it cost more. Deployment would be easier/simpler. I've spent considerable time to improve my deploy process and lower the deploy times but it's still ~2-3min from tag -> deployed which I know I could do faster on just a VM. Also everything gets harder in a lambda, packages/binaries, logging, monitoring, etc.
>> up to 128 concurrent requests per environment > I am fairly confident I could support more capacity with a single t3a.nano instance.
Don't forget that this is referring to 128 concurrent requests per environment. By default, an AWS account can run up to 1,000 concurrent Lambdas, and that number can be increased with support requests.
Of course, the REAL win is that you only pay for what you use. Your t3a.nano is costing you 24/7, and if you want it to scale on demand, your stack will get very complicated very quickly. Lambdas just scale "for free".
> Sometimes things are easily and objectively worse than the alternatives.
That's the most subjective thing one can say.
Everything about running software is made more difficult this way. You might think it would make certain infrastructure aspects easier, but it just changes the semantics of the same problem. It's the same quantity of mess to clean up, but now it's in these really weird piles that are often much harder to access.
> up to 128 concurrent requests per environment
I am fairly confident I could support more capacity with a single t3a.nano instance.