KatInterview

Building a Resumable Multi-Tenant Partner API Ingestor

System DesignModel answer
MediumModel answerSystem Designsystem-designdata-ingestionrate-limiting

Last updated

Design an ingestion service that pulls from thousands of heterogeneous partner APIs with resumable checkpoints, raw-first staging, fair per-tenant throttling, and replayable normalization.

Context

Platforms that sit on top of commerce, CRM, and payment systems must continuously mirror data out of partner APIs: customer profiles, product catalogs, and transaction events. Every partner behaves differently — some paginate with opaque cursor tokens, some with page numbers and offsets, some with a since timestamp. They throttle hard and inconsistently, they sometimes return malformed payloads, and they add, rename, or drop fields with no warning.

You are designing the ingestion tier that sits between those partner APIs and your internal stores.

Required behavior

  • Two sync modes: recurring incremental syncs on a schedule, plus ad-hoc historical backfills triggered by customers or support.
  • Resumable progress: a sync that is paused, cancelled, or interrupted by a worker dying must pick up where it stopped instead of starting over.
  • Raw before normalized: persist the untouched partner payload first, and derive canonical entities from it in a separate stage.
  • Schema drift tolerance: unknown fields, missing fields, or changed types must not drop payloads or stall the pipeline.
  • Replayability: if mapping logic changes or a downstream store loses data, re-derive canonical records from stored raw data without re-calling partners.
  • No double counting: ingestion may deliver a record more than once, but canonical writes must be idempotent so duplicates are invisible.
  • Per-tenant fairness: each connection has its own external quota (roughly 2–40 requests/sec per API key). A slow or failing connection must not starve the rest.
  • Operational visibility: metrics and alerts for sync lag, quota exhaustion, error rates, and dead-letter volume.

Assumed scale

Roughly 25,000 active connections across several platforms; on the order of 300 million records per day (about 3.5K/sec average, up to 15K/sec at peak).

What to produce

Cover the overall architecture, how checkpoint/state is persisted, how rate limiting and fair scheduling work, how errors are classified and retried, and how raw storage plus versioned normalization deliver replayability and drift tolerance. Be explicit about write ordering and which crash scenarios it protects against.

Hints

Hint 1

Run the arithmetic first: at 100–250 records per page, 15K records/sec is only ~50–150 outbound calls/sec — the real bottleneck is per-connection quota and skew, not raw throughput.

Hint 2

Break each sync into page-sized tasks and fix the durable write order to 'raw object → manifest + checkpoint in one transaction → publish via outbox', so a cursor can never advance past data you failed to persist.

Hint 3

Rate limit with a per-(platform, credential) token bucket acquired before the outbound call, and have the scheduler skip connections with no tokens instead of letting workers block on them.

Hint 4

Classify errors into transient, auth, and permanent-request buckets — only transient ones warrant retries; the rest go to a dead-letter queue or trigger pausing the connection.