Skip to main content

Preview — Pro guide

You are seeing a portion of this guide. Sign in and upgrade to unlock the full article, quizzes, and interview answers.

Task & Job Scheduler — LLD (Cron, Queues, At-Least-Once, Idempotent Workers)

LLD for schedulable jobs: cron/one-shot triggers, Run state machine, worker claim+lease, exponential backoff, DLQ, and at-least-once delivery. Aligns with Conductor/Sidekiq-style idempotent handlers vs fake exactly-once.

50 min read 3 sections 1 interview questions
Task Scheduler LLDAmazon SQSNetflix ConductorCron ExpressionAt-Least-OnceIdempotent HandlerExponential BackoffDead Letter QueueObject-Oriented DesignDistributed JobsSEDIE FrameworkJob Queue
IMPORTANT

What Interviewers Are Actually Testing

This is the LLD of behavior + state, not a miniature Kubernetes. The signal is: you model Job and TaskExecution as different objects, you give triggers (one-shot, cron) their own abstractions, and you can articulate at-least-once delivery with idempotent side effects. Wave 'exactly-once' without idempotency and you fail; wave 'Kafka exactly-once' and explain it is effectively-once via idempotent processing and you pass. A staff candidate references durable task engines (open-source Conductor documents at-least-once task redelivery) and fencing tokens as the bridge from LLD to HLD when pushed.

Clarifying Questions

01

In-process (thread pool) or distributed workers?

In-process: locks + priority queue. Distributed: add lease TTL, heartbeats, claim with fencing — state the difference even if code is single-JVM.

02

Recurring: cron, fixed delay, or both?

Cron (wall-clock) is standard for batch; fixed delay for self-scheduling. Model Trigger as interface, CronTrigger and OneShotTrigger as implementations.

03

What happens on failure? retry count, DLQ?

Exponential backoff cap, max_attempts, terminal DEAD with manual replay.

04

Priority and fairness?

Separate queues per priority or one heap keyed by (priority, due_time) — be ready to name starvation risks.

05

Dependencies between jobs (DAG) in scope?

If yes, Job references upstream completion handles — often out of 45m LLD; name Workflow aggregate as v2.

06

Exactly-once execution?

Answer honestly: effectively-once via idempotency; raw exactly-once execution is not the promise — duplicates can occur before commit.

IMPORTANT

Premium content locked

This guide is premium content. Upgrade to Pro to unlock the full guide, quizzes, and interview Q&A.