DEV Community

Discussion on: Serverless or Containers?

Collapse
 
kspeakman profile image
Kasey Speakman

AWS Lambda does have cold start every 4 hrs. The first request to hit after cold start will have increased latency. (Apparently they removed the 5 minute idle cold start.)

Here is an interesting article on cold start perf.

Aside from that, lambda nodes are basically just containers (on Amazon Linux distro) under the covers... running python, node, jvm, dotnet core, etc. In between function executions, the container is frozen (background processes will freeze too, if you started any).

Whereas Docker containers are still running between executions. This allows you to run stateful workflows (i.e. when entities are too large to load/save on every request). And also keep background tasks running between API executions. Those two things are not supported in Lambda. You can actually keep some data in memory between executions, but the container may be thrown away at any time. So it could be useful for caching things (caches can be rebuilt), but for stateful workflows a thrown-away container would lose data.

When you get into auto-scale docker containers, you are probably going to run into some of the same issues as lambda (ephemeral containers). Plus you have to manage a cluster. So it starts to make sense to just use Lambda instead.