50,000 Scheduled Tasks/sec
Sustained peak request volume during high-traffic events.
Execute millions of recurring cron and delayed background jobs reliably with worker heartbeats and distributed locking.
Target production parameters expected in a senior or staff interview round.
Sustained peak request volume during high-traffic events.
Daily active users generating read and write operations.
Projected data ingestion and replication storage capacity.
Strict end-to-end percentile latency SLA constraint.
Establish clear problem boundaries before proposing architectural components.
Step-by-step arithmetic conversions for QPS, storage, and bandwidth.
| Dimension | Calculation Formula | Estimated Result |
|---|---|---|
| Peak Job Dispatch Throughput | 100M jobs/day / 86,400s * 3x top-of-the-hour spike factor | 3,472 jobs dispatched/second |
| Delayed Job Timer Queue Sizing | 10 Million future-scheduled jobs waiting in storage | 10,000,000 active scheduled timer keys |
| Worker Heartbeat Telemetry Ingress | 5,000 workers sending health pings every 5 seconds | 1,000 heartbeat evaluations/sec |
How requests navigate ingress gateways, application logic, caching, and persistence.
Validate job payload contracts, compute initial trigger timestamps, and persist to task database.
Maintain sorted delay timers, scan for jobs where `trigger_epoch <= now()`, and push ready jobs to dispatch queues.
Deliver tasks to assigned worker instances, prevent duplicate concurrent runs, and track lease expirations.
Reclaim jobs from dead workers whose heartbeats have expired and re-queue for execution.
Entity models, indexing, and primary key partitioning.
Composite index on (status, next_run_at) for efficient timer poller range queries.
Index on (job_id, started_at) for execution history and debugging.
Index on last_heartbeat_at for reaper daemon dead-worker detection.
How to defend engineering compromises when challenged by interviewers.
Rationale: Database polling causes massive table locking and index thrashing at scale. Hierarchical timing wheels provide O(1) insert and O(1) expire operations in memory.
Rationale: True distributed exactly-once execution across network partitions is impossible due to the Two Generals problem. At-least-once with client idempotency prevents duplicate side-effects reliably.
Key interview questions and conceptual defenses.
Workers must acquire a distributed lock with a fencing token (or an atomic conditional update `status = RUNNING WHERE status = PENDING`) before starting execution.
The worker's heartbeat lease expires. The reaper daemon detects the missing ping, marks the execution as FAILED, and re-submits the job to the queue.