Design a Sorting Large Data Sets
Design a service that sorts data sets far too large for one machine. A team points it at a folder of input files in object storage, names the key to sort by, and gets back a folder of sorted output files and a manifest. The output must contain exactly the input records, in key order, so that reading the part files one after another gives one sorted sequence.
A typical job is 100 TB: a trillion 100-byte records with 10-byte keys, and it should finish in under 30 minutes on a pool of 250 machines. The hard parts: no machine can hold more than a sliver of the data in memory, every byte has to cross the network once and touch disk several times, one overloaded machine sets the finish time for everyone, and in a 30-minute run on 250 machines, about one machine is likely to die.
Good questions to ask first
Decide what you would assume for each before you look at ours.
- 1How much data per job?
- 2What is a record?
- 3Does the output have to be one file?
- 4How fast?
- 5What machines?
- 6Can machines fail mid-job?
- 7Duplicate keys and stability?
- 8How many jobs at once?
How to spend the 45 minutes
- 5minPart 1: Requirements and scope
- 5minPart 2: Estimates: memory, disk and network passes
- 5minPart 3: API
- 15minPart 4: Architecture, stage by stage
- 15minPart 5: Deep dives and trade-offs