Preparing your design workspace

Loading the problem and your latest saved attempt…

Design a Future-Time Job Scheduler

Schedule durable one-time jobs, including timed JSON delivery to a URL, with safe ownership and explicit uncertain outcomes.

Problem statement

For this exercise, assume clients schedule, cancel, or reschedule one-time jobs with a payload and requested execution instant. A due job must be claimed within ten seconds, must never execute early, and must not produce two committed effects when workers retry or leases expire.

Design durable scheduling, time-ordered discovery, dispatch, worker ownership, idempotent completion, cancellation races, recovery, and observability. Exclude cron recurrence and arbitrary untrusted code execution.

HTTP delivery variant: Accept a scheduling request containing url, timestamp, and data. At the requested timestamp, send data to that URL. For this exercise, assume the transport is an HTTP POST whose JSON body is data, rather than the entire scheduling request.

Retain stable job identity and the baseline scheduling, cancellation, rescheduling, and status operations. The timestamp is a UTC instant. Do not send early; the ten-second target bounds healthy dispatch claiming, not remote network completion.

Assume destinations are validated public HTTPS endpoints, and discuss how outbound requests are bounded and prevented from reaching private services or following unsafe redirects. These transport and destination rules are exercise assumptions.

A remote URL may be non-idempotent. Local leases and completion fences cannot prevent a remote side effect that already happened, and a lost HTTP response does not prove failure. Preserve one authoritative local outcome for each job generation, including outcome-unknown.

Do not automatically repeat an uncertain call to a non-idempotent receiver. Explain what evidence permits safe reconciliation and which delivery guarantee is possible when the receiver does not cooperate.

The baseline no-duplicate-effect invariant requires an idempotent effect boundary; if a receiver supports that boundary, state its stable delivery-key, concurrent deduplication, receipt lookup, and retention contract explicitly. Do not claim exactly-once effects at arbitrary URLs.

Cancellation and rescheduling apply only while a job generation is pending. Once it has been claimed, a lease expiry or HTTP timeout does not reopen those operations; expose or reconcile its outcome instead.

What to build

  1. Clients can create a one-time job with a requested execution instant and stable idempotency key; the HTTP variant accepts url, timestamp, and data and sends data as the JSON POST body.
  2. Clients can cancel or reschedule a pending job without an old schedule later dispatching it.
  3. Workers claim due jobs without early execution and record one authoritative logical outcome across retries; an uncertain non-idempotent external effect remains outcome-unknown.
  4. Operators can inspect pending, leased, succeeded, failed, cancelled, and outcome-unknown jobs.

At scale

  • Assume 50 million pending jobs and 20,000 newly due jobs per second at peak.
  • A healthy due job is claimed within ten seconds of its requested time and is never dispatched early.
  • Retain terminal status and audit history for thirty days.
  • The service remains available through one worker or partition failure without duplicating a committed effect.