Problems / Async and streaming, hard

Scheduled jobs: everything fires at the top of the minute

Asked at Airbnb, Netflix and Uber. A scheduler API calls job runners synchronously, and each job takes 400 ms. Cron schedules line up, so at 6 s and 16 s ten times the usual jobs fire for 3 seconds, and at 9 s a runner dies mid-job.

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

Your goals

Success ≥ 99.9%, no job run twice, no job lost, for at most $18,000 a month.

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 3; 1 of them are hidden until then.

  1. As given. The problem’s own traffic, scheduled failures and seed.
  2. A slow dependency. The main data store or model answers twice as slowly for part of the run.

The traffic

600 requests a second for 20 seconds: 100% job (writes).

The system

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

ComponentIts job hereSettings
Load balancerLoad balancerTraffic enters here.Calls Scheduler API.Layer 4 balancers route by IP and port; layer 7 balancers read HTTP and can route by path or header.–
Scheduler APIApp serviceLoad balancer forwards to it.Calls Job runners.Little's law: throughput ≈ concurrency ÷ latency. 200 slots at 50 ms serve about 4,000 req/s.4 replicas × 100 slots · timeout 4.0 s
Job runnersApp serviceScheduler API calls it.Calls Job runs (Postgres).Little's law: throughput ≈ concurrency ÷ latency. 200 slots at 50 ms serve about 4,000 req/s.8 replicas × 100 slots · timeout 4.0 s
Job runs (Postgres)SQL databaseJob runners calls it.Postgres runs one process per connection, which is why poolers like PgBouncer sit in front of busy databases.8 vCPU · 400 connections

More async and streaming problems