Rapid Multi-Terabyte File Distribution Across Large Server Fleets
System DesignModel answerLast 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:
- Unit conversions connecting file size and network throughput, deriving the absolute baseline transfer time for a single destination machine.
- 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).
- A global fleet capacity proof balancing total required bits received against maximum possible aggregate bandwidth.
- 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.
Model answer
Medium Try it yourself first — then compare your approach, complexity and edge cases.
Part 1: Physical Lower Bound
1. Unit Conversion & Single-Host Ingest Limit
We measure storage sizes using standard metric data definitions ($1\text{ TB} = 1,000\text{ GB} = 10^{12}\text{ Bytes}$) and network throughput in decimal bits per second ($1\text{ Gbps} = 10^9\text{ bits/sec}$):
$$\text{Snapshot Size } (S) = 2\text{ TB} = 2,000\text{ GB} = 2,000 \times 8\text{ Gigabits} = 16,000\text{ Gb}$$
Given a interface bandwidth $C = 25\text{ Gbps}$, the time required for a single machine to ingest the 2 TB file assuming zero protocol overhead is:
$$T_{\text{single}} = \frac{16,000\text{ Gb}}{25\text{ Gbps}} = 640\text{ seconds} \approx 10.67\text{ minutes}$$
No node in the cluster can finish ingesting the payload faster than 640 seconds, regardless of cluster size or peer topology.
2. Network Interface Capacity Models
- Independent Full Duplex: Dedicated 25 Gbps ingress and dedicated 25 Gbps egress. Ingress bandwidth stays at 25 Gbps regardless of outbound forwarding activity.
- Shared Bandwidth Constraint: Total traffic across ingress and egress combined cannot exceed 25 Gbps ($\text{Rate}{\text{in}} + \text{Rate}{\text{out}} \le 25\text{ Gbps}$). To maintain continuous peer-to-peer relaying, a host balancing ingress and egress operates at $\text{Rate}{\text{in}} = \text{Rate}{\text{out}} = 12.5\text{ Gbps}$.
3. Fleet-Wide Conservation Floor
Let $N$ be the number of target machines needing the snapshot. Total bits required fleet-wide is $N \times 16,000\text{ Gb}$.
- Under Shared Bandwidth (12.5 Gbps effective ingress per node during relay):
$$\text{Aggregate Fleet Ingress Rate} = N \times 12.5\text{ Gbps}$$
$$T_{\text{fleet}} \ge \frac{N \times 16,000\text{ Gb}}{N \times 12.5\text{ Gbps}} = \frac{16,000}{12.5} = 1,280\text{ seconds} \approx 21.33\text{ minutes}$$
- Under Independent Full Duplex (25 Gbps full ingress while sending):
$$T_{\text{fleet}} \ge \frac{N \times 16,000\text{ Gb}}{N \times 25\text{ Gbps}} = \frac{16,000}{25} = 640\text{ seconds} \approx 10.67\text{ minutes}$$
4. Scale Invariance with Fleet Size ($N$)
Because $N$ appears in both total required ingress volume ($N \cdot S$) and aggregate fleet intake rate ($N \cdot C_{\text{effective}}$), the term $N$ cancels out completely:
$$T_{\text{floor}} = \frac{N \cdot S}{N \cdot C_{\text{effective}}} = \frac{S}{C_{\text{effective}}}$$
Every additional node contributes its own network pipe to the global pool. Consequently, distributing to 2,000 nodes takes essentially the same time as distributing to 200 nodes.
Bootstrap Overhead Note: The theoretical minimum assumes steady-state peer participation. In the initial phase, only the origin host possesses data. The aggregate upload capacity expands exponentially ($\approx \mathcal{O}(\log N)$ rounds) as nodes acquire their first chunks. For $N = 2,000$, this warm-up adds only a minor delay (around 30–60 seconds) on top of the theoretical limit.
Part 2: Architecture & System Design
Naive Baseline Performance
If the origin machine pushes the 2 TB file directly to all $N$ workers over its 25 Gbps connection:
- Total outbound bits from origin: $N \times 16,000\text{ Gb}$.
- Maximum origin egress speed: 25 Gbps.
$$\text{Duration}(N) = \frac{N \times 16,000}{25} = N \times 640\text{ seconds}$$
- For $N = 200$ nodes: $200 \times 640\text{ s} = 128,000\text{ s} \approx \mathbf{35.5\text{ hours}}$.
- For $N = 2,000$ nodes: $2,000 \times 640\text{ s} = 1,280,000\text{ s} \approx \mathbf{355.5\text{ hours (14.8 days)}}$.
This linear growth ($\mathcal{O}(N)$) highlights why origin-centric distribution is infeasible for production environments.
Peer-Assisted Architecture
+--------------------+
| Centralized |
| Tracker / Control |
+---------+----------+
|
+---------------+---------------+
| Manifest & Swarm Metadata |
v v
+---------------+ +---------------+
| Origin Seed | | Worker Node |
| (Initial Host| | (Peer A) |
+-------+-------+ +-------+-------+
| ^
| Initial Chunks | Chunks
v v
+---------------+ +---------------+
| Worker Node |<------------->| Worker Node |
| (Peer B) | Chunks | (Peer C) |
+---------------+ +---------------+
1. Data Segmentation & Storage Manifest
- Chunk Sizing: The 2 TB snapshot is partitioned into fixed-size 32 MB blocks (yielding 62,500 total chunks).
- Trade-off: Smaller chunk sizes (e.g., 2 MB) enable faster initial propagation across peers but scale up control-plane metadata overhead. Larger chunks (e.g., 512 MB) minimize tracking state but increase penalty cost if a transfer fails mid-block.
- Manifest Distribution: A lightweight manifest file containing total chunk count, offset mappings, and SHA-256 hashes per block is generated and signed by the origin, then distributed to all target nodes prior to data streaming.
2. Swarm Management & Selection Strategies
- Metadata Management: A lightweight Tracker service maintains a bitfield registry of which nodes possess which chunk indices. Nodes refresh their availability via periodic heartbeat messages.
- Rarest-First Fetch Strategy:
- Nodes query the tracker or exchange bitfields with direct peers, then prioritize downloading chunks held by the lowest number of hosts.
- Rationale: Rarest-first selection prevents bottleneck bottlenecks late in distribution, where the entire fleet is stalled waiting for a single remaining chunk hosted by only one seed.
- Dynamic Connection Choking (Tit-for-Tat): Nodes prefer uploading to peers that provide them high download rates, naturally routing traffic away from slow links.
3. Handling Stragglers
- Performance Monitoring: The tracker monitors peer ingest/egress rates. Nodes falling below a minimum threshold (e.g., $< 2\text{ Gbps}$) are labeled as stragglers.
- Deprioritized Seeding: Active nodes avoid requesting data from stragglers to prevent bottlenecking their own inbound pipelines.
- Speculative Downloading (Endgame Mode): Once a node has pulled 99% of its missing chunks, it issues duplicate requests for remaining chunks to multiple fast peers simultaneously, discarding redundant arrivals.
4. Fault Tolerance & Integrity
- Peer Failures: If a node crashes mid-stream, its active connections drop. Peer discovery ensures neighboring nodes immediately switch to alternative sources for missing blocks.
- Corruption Prevention: Upon receiving a 32 MB chunk, a node verifies its SHA-256 checksum against the signed manifest before marking the chunk valid in its bitfield. Corrupted chunks are immediately re-requested.
- Origin Safety: The origin node remains online throughout the deployment as a seed of last resort for any rare chunks.
5. Fleet Readiness & Safe Cutover
- State Reporting: After assembling all 62,500 validated chunks, a host verifies the global snapshot hash and transitions its status to
READYin the control plane while continuing to seed missing blocks to remaining peers. - Atomic Fleet Cutover: The search coordinator monitors readiness. Once a configured quorum (e.g., 99% of nodes) reports
READY, a coordinated signal is broadcast. Nodes atomically swap symlinks to point to the new snapshot and reload search indexes in memory, preserving zero downtime for ongoing search queries.