EC2 vs Lambda
When to run long-lived servers versus event-driven functions.
Overview
What is being compared
EC2 gives you a virtual machine that runs continuously and suits long-lived server processes. Lambda runs your code only when something triggers it and charges for each invocation's duration.
- Runtime model — Always-on virtual machine — Runs only when triggered
- Best-fit load — Predictable, steady throughput — Spiky or event-driven traffic
- Control — Custom OS, kernel parameters, file system mounts — No servers to configure
- Hardware — GPU and specialized hardware — No GPU option
- Operations — You manage AMIs, patching and Auto Scaling Groups — Zero server management
- Scaling — You configure it — Automatic, to thousands of concurrent executions
- Pricing — Cost-optimized at scale with Reserved Instances — Pay per request, 1 million free requests per month
- Integrations — Whatever you install — Native triggers from S3, DynamoDB, SQS and API Gateway
Sign up free to read the full topic
More Comparisons topics
Start free on Cariara · Coding problems · System design studio