Every server you launched, you had to set up, patch and pay for by the hour. Some work doesn't need a server of its own.
Lambda runs a function, your code, when something happens: a file lands in S3, a message arrives, a web request comes in. It runs for seconds, then stops. You pay per call, and nothing for the time in between. This is called serverless: there are servers, but you never manage them.
| EC2 | Lambda | |
|---|---|---|
| You manage | the server: OS, patches, scaling | only your code |
| Runs | all the time | when an event calls it |
| You pay | per second it runs | per call |
| Good for | long-running apps | short jobs after an event |
To call a function from the web, put API Gateway in front of it, or give it a function URL.
Containers (from the Docker course) run on ECS, AWS's container service. With Fargate, ECS runs them without you choosing or patching any servers.
Parts of an app can also talk through AWS instead of directly:
| Service | Does | Example |
|---|---|---|
| SQS | a queue: one side puts work in, the other takes it out when ready | orders waiting for the warehouse |
| SNS | notifications: one message to many subscribers | "order shipped" by email and to the stock system |
The checkout no longer waits for the warehouse, and a slow part doesn't slow the rest.