KatInterview

Rapid Multi-Terabyte File Distribution Across Large Server Fleets

System DesignModel answer
MediumModel answerSystem Designsystem-designdistributed-systemspeer-to-peer

Last updated

Derive the fundamental physical time limits for distributing a 2 TB file to up to 2,000 servers over 25 Gbps links, then design a peer-assisted distribution protocol to match it.

You need to deploy a 2 TB search index update across an operational cluster comprising between 200 and 2,000 worker machines. Every machine in the cluster—including the single origin host holding the master snapshot—is provisioned with a 25 Gbps network interface. This network capacity is shared across active ingress (download) and egress (upload) operations.

Assume a flat physical network topology: any host can establish a link to any other host at full line speed without encountering top-of-rack or inter-switch bottlenecks.

Part 1: Physical Lower Bound

Calculate the absolute minimum time required to land the complete 2 TB payload onto every machine in both a 200-node and a 2,000-node cluster.

Your analysis must explicitly detail:

  1. Unit conversions connecting file size and network throughput, deriving the absolute baseline transfer time for a single destination machine.
  2. The impact on total transfer duration depending on whether the 25 Gbps capacity is shared between simultaneous ingress/egress vs. available independently in full duplex (25 Gbps in + 25 Gbps out).
  3. A global fleet capacity proof balancing total required bits received against maximum possible aggregate bandwidth.
  4. Why the theoretical time floor remains almost completely independent of host count ($N$) when machines are allowed to forward chunks they have already ingested.

Part 2: System Design & Protocol Evolution

Describe a naive sequential/parallel unicast baseline (origin machine pushing directly to all workers) and quantify its runtime for 200 and 2,000 nodes. Explain why it fails to scale.

Then, design a chunked, peer-assisted distribution system that approaches the theoretical floor. Address the following design aspects:

  • Data Segmentation & Overlay: How the 2 TB file is broken down and exchanged among peers to maximize total link utilization.
  • Chunk & Peer Selection: Strategies nodes use to decide which pieces to pull and from whom, avoiding rare-chunk bottlenecks.
  • Straggle Mitigation: How to prevent degraded network links or underperforming nodes from blocking fleet completion.
  • Fault Recovery: Handling mid-transfer node crashes without losing rare chunks or corrupting data.
  • Verification & Cutover: How nodes confirm dataset integrity and coordinate switching live search traffic to the newly received index.

Hints

Hint 1

Convert Terabytes to Gigabits using 1 Byte = 8 bits (e.g., 2 TB = 16,000 Gb). Ensure network rate units match data size units accurately.

Hint 2

Consider aggregate fleet bandwidth: if N machines are receiving data, total capacity scales with N, offsetting the N-fold increase in required data delivery.

Hint 3

Think about how BitTorrent uses rarest-first piece selection to keep chunk distribution uniform across the network.