BLUEPRINT #05Storage & Search
Design a Distributed Job Scheduler & Task Execution Queue
Referenced Architecture Primitives (6)
Click any primitive to study its algorithmic deep dive10-Stage Structure:1. Requirementsβ2. Sizingβ3. Topologyβ4. Data Modelβ5. AWS Topologyβ6. Deep-Diveβ7. Failuresβ8. SRE Playbooks
1. Problem Statement & Scope
System Mission
Design a distributed, highly available, fault-tolerant Job Scheduling and Task Execution platform (similar to Temporal, Quartz, or AWS EventBridge Scheduler) capable of scheduling and executing billions of delayed, recurring (cron), and one-off tasks with exact-once semantics, priority queuing, dynamic worker auto-scaling, and execution status tracking.
Functional Requirements
- Schedule Delayed & Cron Tasks (
POST /v1/jobs): Schedule jobs with specific future execution timestamps (delay), recurrence intervals (cron expressions), or instant execution. - Prioritized Task Dispatch: Execute tasks based on priority tiers (
CRITICAL,HIGH,DEFAULT,LOW). - Task State & Lifecycle Tracking: Track job lifecycle states (
SCHEDULED,DISPATCHED,RUNNING,SUCCEEDED,FAILED,CANCELLED). - Automated Retries & Exponential Backoff: Automatically retry failed tasks with configurable retry policies and Dead-Letter Queue (DLQ) routing.
- Worker Heartbeating & Lease Renewal: Ensure long-running tasks (> 10 minutes) renew execution leases; un-heartbeated tasks are automatically rescheduled.
Non-Functional Requirements (SLAs/SLOs)
- High Availability: uptime SLA.
- Execution Timing Accuracy: Tasks execute within of scheduled execution time.
- Durability: (11 9s) zero task loss guarantee before execution.
- Scale: Support active scheduled tasks and peak dispatch rate.
2. Capacity & Scale Estimation
Traffic Calculations
- Active Scheduled Tasks: 100 Million tasks ().
- Daily Completed Task Volume: 500 Million tasks/day.
- Average Dispatch Throughput:
- Peak Dispatch Throughput ( top of the hour burst): .
Storage & Memory Estimation
- Task Definition Size:
job_id(16 Bytes),tenant_id(16 Bytes),target_url / handler(128 Bytes),payload_json(512 Bytes),schedule_cron(32 Bytes),next_run_epoch_ms(8 Bytes),retry_policy(64 Bytes) .
- Database Storage (100M active tasks):
- Historical Execution Log (30-Day Retention in S3):
3. AWS-First High-Level Architecture
Interactive Architecture DiagramSynthesizing vector architecture diagram...
4. API Interface Design
1. Schedule a Job
httpPOST /v1/jobs Host: scheduler.api.aws.internal Content-Type: application/json Authorization: Bearer <jwt_token> Idempotency-Key: idemp_job_8492019 { "job_name": "generate_monthly_invoice", "schedule_type": "CRON", "cron_expression": "0 0 1 * *", "target": { "type": "HTTP_WEBHOOK", "endpoint": "https://billing.internal.aws/invoices/generate", "method": "POST", "timeout_seconds": 120 }, "payload": { "tenant_id": "tenant_992", "currency": "USD" }, "priority": "HIGH", "retry_policy": { "max_retries": 3, "backoff_multiplier": 2.0, "initial_interval_seconds": 10 } } Response: 201 Created { "job_id": "job_9847291048", "status": "SCHEDULED", "next_run_time_ms": 1718000000000 }
Part 2: Production Deep-Dive Locked1 Coin = 24 Hours
Unlock Complete Architecture & Production Runbooks
Your Balance:40 Coins
You have explored the free architectural preview (~49%). Spend 1 Coin to unlock the remaining 6 production deep-dive sections for a full 24 hours.
Sections Included in This 24-Hour Pass:
5. Data Models & Storage Architecture
6. Component Deep Dives & Workflows
7. Architectural Trade-Off Matrix & Primitive Links
8. Critical Edge Cases & Distributed Failure Modes
9. Production Pitfalls & Anti-Patterns (The "Gotchas")
10. Production Runbook & Operational Best Practices
Keeps page unlocked for exactly 24 hoursSpend coins to fund LLM & compute infrastructure