KatInterview

Multi-Region File Distribution with Tenant Isolation

System DesignModel answer
MediumModel answerSystem Designdistributed-systemsmulti-tenancydata-replication

Last updated

Design a scalable pipeline that replicates large immutable files from a central location to multiple per-tenant destinations with guaranteed delivery and strict isolation.

You're designing a distributed system for a multi-tenant platform. The system must replicate large immutable files—such as recorded customer calls—from a central production location to multiple storage endpoints specific to each tenant. Every tenant configures their own set of target locations, and files belonging to one tenant must never be accessible to another.

The business requires strong guarantees: no file may be lost, and for audit and compliance purposes, the system must report whether each file has successfully reached all of its intended destinations.

Approach this design incrementally. Begin with a minimal working design for a single source and destination, then layer in asynchronous distribution to multiple endpoints, robust failure handling, and finally tenant isolation and fairness under load.

Assumptions and Open Questions

  • File size distribution and daily throughput are undefined—make parametric estimates and ask for concrete numbers.
  • Files do not change after creation.
  • Each tenant's destination list is stored as configuration and may evolve over time.
  • Whether the source retains or deletes files post-transfer is a business decision to clarify.

Questions to Ask

  • What are typical and maximum file sizes? What is the daily file creation rate at peak?
  • What is the acceptable replication latency from file creation to availability at all destinations?
  • Should the source preserve files after successful replication, or delete them to save space?
  • Are destinations platform-managed storage in other regions, or customer-controlled endpoints? What protocols are supported?
  • Should a destination file become visible only after the entire transfer is verified?
  • Are there data residency or sovereignty constraints that restrict where a tenant's data may transit or temporarily reside?

Part 1 — Minimal Working Design

Describe a straightforward design for replicating a single file to one destination per tenant. Identify the core components, data flow, and the limitations that make this approach insufficient.

Expected coverage:

  • End-to-end component flow with clear responsibilities
  • Metadata tracking for files and their transfer state
  • Why a synchronous approach fails for large files and many tenants

Part 2 — Asynchronous Multi-Destination Replication

Extend the design to handle fan-out: each file is replicated to all destinations configured for its owning tenant. Use message queues and worker pools. Explain how replication work is created, distributed, and tracked, and how large files are transferred efficiently without blocking.

Expected coverage:

  • Mechanism for generating per-destination transfer tasks from file events without loss
  • Chunked, resumable transfers with checksum verification
  • Decoupling destination availability from overall system health
  • Data model and APIs for monitoring replication progress

Part 3 — Handling Failures and Ensuring Consistency

Workers crash, destinations become unreachable, events are processed multiple times, and data corruption occurs in transit. Show how the design guarantees eventual delivery of every file to every destination, intact and without duplication, and ensures partial transfers are never exposed.

Expected coverage:

  • Retry policies, task leases, and dead-letter queues for failed tasks
  • Idempotent operations and atomic commit at destinations
  • Checksum validation and periodic reconciliation to detect missed work
  • Graceful degradation during prolonged destination outages

Part 4 — Tenant Isolation and Fairness at Scale

Demonstrate how the design enforces strict tenant boundaries so files cannot reach unintended destinations, and how it maintains performance and fairness when tenant workloads vary widely or the tenant count grows.

Expected coverage:

  • Credential and encryption-key scoping per tenant
  • Fair queuing or scheduling to prevent one tenant from monopolizing resources
  • Horizontal scaling strategy and identifying the true bottleneck (cross-region bandwidth)

Hints

Hint 1

Start by clarifying file size and throughput—these drive storage, network, and worker capacity decisions.

Hint 2

Use message queues to decouple file production from replication, and partition work by destination to isolate failures.

Hint 3

Idempotency and atomic visibility (write-then-rename or upload-then-commit) prevent partial files from being read.