KatInterview

Design a Delayed Webhook Delivery Service

System DesignModel answer
MediumModel answerSystem Designsystem-designschedulingqueues

Last updated

Design a system that accepts a target URL, a future timestamp, and a JSON payload, then reliably delivers that payload via HTTP at the scheduled time.

Delayed Webhook Delivery Service

Your task is to design a backend service that lets callers schedule an outbound HTTP delivery for a future point in time. Callers submit a request body like this:

{
  "url": "https://example.com/api",
  "timestamp": "2026-07-05T12:30:00Z",
  "data": { "...": "..." }
}

The service persists the request, waits until the wall-clock time matches timestamp, then POSTs data to url. The caller's own server is not involved again until that delivery arrives.

What to cover

  • The API clients use to submit (and optionally manage) scheduled deliveries
  • How scheduled deliveries are stored durably
  • How the system efficiently finds and dispatches deliveries that are due, at scale, without double-delivery
  • What happens when a delivery fails — the target returns an error, is slow, or is unreachable
  • How the system recovers when one of its own components crashes mid-flight
  • Any security measures around which URLs the service is allowed to call

Constraints and given facts

  • Each incoming request contains exactly three fields: a URL, an ISO 8601 UTC timestamp, and an arbitrary JSON payload.
  • The service is responsible for making the outbound call at the scheduled time.

What is NOT given — clarify or state assumptions

The following are deliberately left open. In an interview you would ask about them; here, state your assumptions explicitly before designing:

  • The HTTP method, headers, and timeout for the outbound call
  • Required delivery precision (sub-second, a few seconds, within a minute?)
  • Whether early delivery is ever acceptable
  • How to handle timestamps in the past or far in the future
  • What counts as a successful delivery, and how many retries are appropriate
  • Expected submission and delivery throughput at peak load
  • Whether many deliveries can share the same timestamp ("thundering herd")
  • Whether clients need to cancel, update, or look up a scheduled delivery, or receive a failure notification
  • Whether callers are trusted and whether any URL on the internet is a valid target

Hints

Hint 1

Before drawing any boxes, nail down delivery precision and throughput — a service that needs sub-second accuracy with 10k deliveries/sec looks very different from one that tolerates a 5-second window at 100/sec.

Hint 2

Think about how you index scheduled deliveries for efficient polling. A naive 'scan everything' query won't survive at scale — consider what a time-bucketed structure or a priority queue in a durable store buys you.

Hint 3

At-least-once delivery is much easier to guarantee than exactly-once, but it shifts the deduplication burden to receivers. Be explicit about which guarantee you're offering and what a receiver needs to do to be safe.