EC2 and Lambda
Compare server-based and event-driven compute for feedback processing.
The workshop compares EC2 and Lambda before selecting Lambda for short, event-driven backend work.
EC2: control over a virtual server
EC2 gives you a virtual machine with a choice of operating system, instance capacity, and software stack. Custom machine images and dependencies make it useful when the application needs operating-system access, long-running processes, or a persistent server.
You configure scaling groups and load balancing when the workload needs them. Running instances incur compute charges even when application traffic is low, and the team remains responsible for operating-system and application maintenance.
Lambda: functions triggered by events
Lambda runs functions in response to API requests, S3 events, or queue messages. It manages the execution infrastructure and scales within the function’s configuration and account quotas. Standard Lambda functions have a maximum execution timeout of 15 minutes; longer workflows need another execution strategy. See Lambda quotas.
Supported runtimes include Node.js, Python, Java, and .NET; other languages can use custom runtimes or container images. Persist application state in a database or object store rather than relying on an execution environment surviving between requests.
Compare the trade-offs
| Decision | EC2 | Lambda |
|---|---|---|
| Control | Operating system and software stack | Function code and execution configuration |
| Scaling | Configure instances, scaling, and balancing | Managed scaling within quotas |
| Charging model | Instance capacity while running | Requests and execution duration, plus optional features |
| Execution | Suitable for persistent processes | Bounded function executions |
| State | Can host a stateful server | Keep durable state outside the function |
| Typical fit | Custom dependencies or long-running applications | API handlers and event-driven processing |
Lambda fits this example because uploads arrive unevenly and trigger discrete processing steps. File preprocessing that exceeds its limits should be split into stages or assigned to another compute service. Compare costs using the actual region, workload, and billing options rather than assuming one service is always cheaper.