I'm hoping someone will correct me if I'm missing something. Otherwise it seems like Lambda isn't really suited to use-cases where random latency spikes would degrade user experience.
I'm hoping someone will correct me if I'm missing something. Otherwise it seems like Lambda isn't really suited to use-cases where random latency spikes would degrade user experience.
The Lambda runtime is exceedingly slow at that on the 128MB tier. This is in fact the case for Django apps, even in their default state.
Now here's where the fun fact starts: If a function times out during cold start, it hasn't successfully been warmed. That means upon its next trigger, it will coldstart again.
Now lets say you deploy a tiny little function over wsgi. You see in your metrics that it takes an avg of 200ms... now, you're a smart dev, you set its global timeout to 3 seconds down from the default of 30 seconds because you don't want to get billed more than necessary. But as it turns out, the cold start takes on average 10 seconds. Your function now never successfully completes.
It was not meant to run an entire framework in. If you’re reaching for an entire framework to run a simple function in a lambda, I’d bail on one or the other. Don’t use a framework, or don’t use lambda.
Example: I have an API in Django which uses DRF, served on a classic web server instance behind load balancers etc. Parts of that API, which have the same authentication/business logic/etc, are much more suited to lambda, I'm sure it's not hard to imagine :)
That is, the cost of idle time is shifted from your account to their account. This sets up a bit of a race: Amazon's goal is to have as few hidden warm instances for as little time as possible. The user's goal is to have as many hidden warm instances as possible for as long as possible.
This is where you start to see pinging to provoke AWS into keeping a warm copy. As time goes on they will have a growing incentive to prevent tricks like these from working.
At the moment, on the economics, hosted FaaSes will always have this tension. Self-hosted FaaSes open up the possibility of setting your own policy for trading latency against idle cost.
Disclosure: I am part of a team working on Project Riff, a FaaS.
if you already have a K8s cluster it's probably cheaper to just create your application regulary and use it like that. No need to use a FaaS which complicates your whole setup for no additional benefit.
As it happens Riff and most other FaaS projects are built on kubernetes.
I still have these resources idle, when I use Riff.
Most folk want cold starts for economic reasons and warm starts for performance reasons. In a hosted setting you can't truly set your policy, you can only try to encourage by external stimuli.