KatInterview

Five Backend Designs: Callbacks, Geo Search, Chat, Pipelines, Payments

System DesignModel answer
MediumModel answerSystem Designsystem-designwebhooksgeospatial-index

Last updated

Sketch five independent large-scale backends in one time-boxed session: event callbacks, nearby-place search, team messaging, a CI/CD engine, and payment processing.

Overview

You have one onsite-style session to sketch five unrelated backend systems. Breadth and judgment matter more than completeness. For each system, give a crisp design, name its dominant bottleneck, and spend your time on the one or two hardest trade-offs. Reuse patterns across systems only where they genuinely fit.

For every system, be ready to cover:

  • Requirements, stated assumptions, and the back-of-the-envelope numbers behind your choices
  • Main components and how they fit together
  • Data model and storage choices
  • How you reach the scale, availability, and latency targets
  • How you handle failure, retries, and consistency

Before designing, state each system's read/write ratio and its dominant bottleneck. You may simplify, but say so.

Questions to raise up front

  • How deep should each system go? If forced to pick, where should you go deepest?
  • For each system, which axis matters most: throughput, tail latency, durability, or cost?
  • Where must correctness beat availability (no lost events, no double charges), and where may the system degrade?
  • What is the read/write ratio, and is eventual consistency acceptable on reads?
  • Is a single region enough for a first pass, or is multi-region required?

System 1: Event-triggered callback (webhook) delivery

Clients register a subscription that maps an eventId (string or number) to one callback URL. Each eventId maps to exactly one URL. When an event fires, the system sends an HTTP request carrying the event data to that URL. Clients can query per-event delivery status: success, failure, and the history of retry attempts.

  • Scale: up to 1 billion events/day (about 11.6k/s on average, with peaks of 3-5x).
  • Accepted events must never be silently lost. At-least-once delivery is fine, and receivers dedupe with idempotency.
  • Delivery within a few seconds is acceptable.
  • Multi-tenant, with only authorized clients allowed to manage their own subscriptions.

Cover APIs, storage, ingestion, dispatch workers, retries, and monitoring.

System 2: Nearby places search

Build a service that manages and searches places worldwide. Each place has id, name, location (lat/lon), place_type, and optional metadata (rating, address, hours).

  • Create, update, and delete places.
  • Search by user location and place type, returning the N closest places, optionally within a maximum radius. Rank mainly by distance, with secondary signals such as rating.
  • Hundreds of millions of places, high read volume, p95 search latency under 100 ms.
  • Writes may take a while to become visible.

Cover storage, geospatial indexing, type and attribute filtering, global sharding and replication, hotspots, and caching.

System 3: Team messaging

Design a messaging platform with 1:1 and group conversations.

  • Send messages, create groups, add and remove members (keep permissions simple).
  • Notify recipients of new messages.
  • Support images and other media, stored efficiently outside the main message store.
  • Let users delete their own messages. Clarify whether that means delete-for-everyone or hide-for-self.
  • Many concurrent users, near-real-time delivery to online users, durable and queryable history, and graceful handling of reconnecting clients.

Cover the services, how real-time connections work, the data model, message versus media storage, per-conversation ordering and reliability, and deletion.

System 4: Distributed CI/CD workflow engine

Design an engine that reacts to repository events (push, pull request opened, tag created, schedule) by running workflows defined as config files (e.g. YAML) stored in the repo itself.

  • Detect events and map them to workflows.
  • Create a run with multiple jobs and steps, and schedule jobs onto a distributed pool of container or VM runners.
  • Manage the run lifecycle: queueing, execution, retries, timeouts, cancellation. Store logs and artifacts, and report status back to the git host.
  • Multi-tenant, with tens to hundreds of thousands of concurrent runs, fair scheduling and rate limiting across orgs, and strong isolation between workflows.

Cover event ingestion, locating and parsing the config from the triggering commit, orchestration and job dependencies, runner infrastructure, storage, scaling, and failure handling.

System 5: Payment processing

Design a payment processing backend that accepts charge requests from merchants, talks to external payment providers, and records the outcome. Correctness dominates here: no double charges and no unrecorded money movement. Cover the API, idempotency, the ledger and data model, handling provider timeouts and failures, reconciliation, and security.

Hints

Hint 1

Use the same skeleton for every system: requirements, rough numbers, components, data model, failure handling. Then pick the single hardest trade-off in each (retry policy, geo index choice, ordering, fair scheduling, double-charge prevention).

Hint 2

Look for shared primitives: a durable partitioned log plus worker fleet (callbacks, chat fan-out, CI jobs), idempotency keys (callbacks, payments), and per-tenant quotas (callbacks, CI, payments). Do not force a fit where eventual consistency is fine, as in place search.

Hint 3

For geo search, index by cell (geohash, S2, or H3), scan the target cell and its neighbors, then re-rank by exact distance. For chat, partition by conversation ID so ordering and history fall out naturally. For payments, write the ledger and an outbox entry in one transaction and make every external call idempotent.