Problems / Cloud and cost, medium

One function starves the account

Two Lambda functions share an account: the customer API (about 100 ms a call) and a report export (about 4.5 s a call). Exports run 240 a second at month end. Neither has reserved concurrency, and the account limit is 1,000.

Unlock it once for 15 credits; everything inside it is free (runs, changes, Submit, results, hints). Sign in with Google to start; new accounts get free credits.

Your goals

Keep the API’s success at 99.9% or more. Exports may wait.

Test cases

Like a coding problem, a solution has to pass every case, not just the one it was built for. Submit in the lab runs all 4; 1 of them are hidden until then.

  1. As given. The problem’s own traffic, scheduled failures and seed.
  2. Peak hour. 25% more traffic than the problem states, with the same failures.
  3. A slow dependency. The main data store or model answers twice as slowly for part of the run.

The traffic

400 requests a second for 120 seconds: 40% api (reads), 60% export (reads).

The system

What each component does in this design, and what calls it. The simulator mimics each one from these settings.

ComponentIts job hereSettings
API Gateway (HTTP API)API gatewayTraffic enters here.Calls Customer API (Lambda), Report export (Lambda).Gateways centralise auth, rate limits and routing so each service does not reimplement them.100000 slots · 600,000 calls/min
Customer API (Lambda)Serverless functionAPI Gateway (HTTP API) forwards to it for /api.Calls DynamoDB.Serverless functions scale per request, but a cold start adds latency to the first call.1000 slots
Report export (Lambda)Serverless functionAPI Gateway (HTTP API) forwards to it for /export.Calls DynamoDB.Serverless functions scale per request, but a cold start adds latency to the first call.1000 slots
DynamoDBKey-value storeCustomer API (Lambda) calls it. Report export (Lambda) calls it.Key-value stores spread keys over partitions; one very popular key can overload a single partition.40 partitions × 3,000 ops/s

More cloud and cost problems