Back to sketch

SYSTEM DESIGN SKETCHBOOK / PRACTICE SHEET / NO. 21

Design a system to sort a 100 TB dataset

Intermediate · 35 min · Data pipelines & analytics

A data team has 100 TB of records spread over thousands of files and needs them globally sorted by key, so downstream jobs can merge-join and binary-search them. You have a cluster for a few hours and need a plan that finishes on time even when some machines misbehave.

Requirements

  • Produce output files that are each sorted, where every key in file i is less than or equal to every key in file i+1.
  • Every input record appears in the output exactly once.
  • Survive machine failures without restarting the whole job.

Constraints and assumptions

  • 100 TB of 100-byte records with 10-byte keys, stored as 10,000 input files of 10 GB in object storage.
  • 100 machines, each with 128 GB RAM, 4 NVMe drives (about 2 GB/s each), and a 25 Gbps network link.
  • Object storage delivers about 1 GB/s of reads or writes per machine.
  • Keys are skewed: some key prefixes are far more common than others.
  • The job must finish within 2 hours.

Out of scope for the first sketch

Continuous or incremental sorting of new data · Sorting records by more than one key · Encryption and multi-tenant isolation

Draw your design

Rough math and notes

Done on paper? Compare with the worked approaches