Scenario / Async processing

Message Queues & Background Workers - Interactive Scenario

An email delivery platform where sending, rendering, and delivery stats all compete for the same resources. Moving work off the request path is the only way to keep the API responsive.

Run this scenario

Briefing

Asynchronous processing & work queues

Async processing moves slow or non-critical work from the request path into queues and workers.

A fast acknowledgment can protect user latency even when the actual work finishes later.

The fastest way to make an API responsive is to stop doing slow work inside the request.

  • Queue work that does not need to finish before the response.
  • Scale workers when queue depth grows.
  • Watch backpressure so delayed work does not become invisible failure.

Contract

Uptime

99.7%

P95 latency

140ms

Budget

$580/mo

Traffic shape

Flash-sale surge with a steep ramp and sustained peak. Baseline 150 users; peak around 2,600 users over 54 hours.

Available components

Server

HTTP request handler Every web app needs at least one server. More servers let you handle more simultaneous requests before latency starts climbing.

Postgres

Primary data store Without a database, your app has no memory. Most dynamic requests eventually depend on it.

Queue

Async job buffer Moving background work out of the request path keeps the app responsive even when extra processing is needed.

Worker

Background job processor Separating background work keeps checkout, page loads, and other user actions from competing with batch processing.

LB

Load balancer If you run more than one server, something needs to decide where each request goes. That is the load balancer.

Redis

In-memory cache layer Popular pages, profiles, and product data often get requested again and again. Serving those from memory is much faster and cheaper.

Stream

Durable event stream Streams are shock absorbers for high-volume ingestion and fan-out systems where one producer feeds many downstream consumers.

Analytics

Async metrics sink Analytics traffic can be high-volume and noisy. Keeping it async prevents dashboards and event collection from hurting core product latency.

Common mistakes

  • Retries need backoff, priority, and enough worker capacity to avoid self-inflicted load.
  • Queues need dead-letter handling and retry limits.
  • Telemetry should be isolated behind async sinks before it grows noisy.
  • Streams and workers must scale together to control backlog.

Interview adjacency

  • Design an email system
  • Design async jobs
  • Design notification delivery