AWS Lambda
medium 25 minAWS Lambda runs your function when an event arrives and stops charging when it ends.
When it comes up
The moments this idea belongs in a design interview, and the moments it does not.
Signals
When to bring it up
| You hear | Say | Because |
|---|---|---|
| Resize each uploaded photo | S3 event to a function | Short, independent, spiky |
| Ten requests a day | A function | Nothing idles |
| 20,000 steady requests per second | Containers, maybe a function at the edges | Always busy, so compare cost |
| Encode a two-hour film | A container task or split steps | Over the run time |
| Fifty milliseconds at p99.9 | Provisioned concurrency or containers | Cold starts sit in the tail |
Options
Explain your choices
Orders arrive in bursts and each needs a slow payment call. How do you run it?
BreaksAPI Gateway to a function that pays
- How
- The customer waits for the whole call.
- Limit
- A slow provider multiplies concurrency, throttles everyone, and retries can charge twice.
- Choose when
- Low traffic and a fast provider.
WorksAsynchronous invocation
- How
- Return at once, let Lambda's queue hold the event.
- Limit
- Little control over the queue, only two retries on error.
- Choose when
- Occasional work that may be lost to a destination.
StrongSQS with maximum concurrency
- How
- Queue the order, cap the mapping at what the provider accepts, pass an idempotency key, report partial failures, use a dead-letter queue.
- Limit
- The result comes later, so the client must poll or be told.
- Choose when
- Bursts in front of a limited dependency.