datarekha
MLOps Medium Asked at AmazonAsked at Capital OneAsked at Netflix

When would you choose AWS Lambda instead of ECS, and when would you choose ECS?

The short answer

Choose Lambda for short, event-driven, bursty work that fits its runtime and packaging constraints and keeps durable state external. Choose ECS for long-running APIs or workers, custom containers, stable processes, and workloads needing explicit CPU, memory, networking, or runtime control. ECS can host stateless or stateful software; critical state should still be externally durable.

How to think about it

Lambda excels when work is naturally triggered by an event, finishes within the function limit, and benefits from per-invocation scaling: file processing, schedules, webhooks and glue code. ECS schedules containers and fits continuously running APIs, steady queue consumers, custom sidecars and jobs needing precise resources or longer execution.

The state question is separate. Lambda is stateless by design. An ECS task may retain memory while it runs, but a replaceable container is not a durable database.

Learn it properly System design boundaries

Keep practising

All MLOps questions

Explore further

Skip to content