</> MAANG.io

Expert

Design landmark systems in depth, from Dynamo, GFS, Bigtable and Kafka to payments and ads pipelines.

0 of 232 solved 0%

Section 9: The Last Task Sets the Clock - Deep Dive: Stragglers, Skew & Bad Records

Executive Summary: A job ends when its last task ends, so the tail sets the job time. Three tail causes look identical on a status page. A slow machine (w-1555 at 1/4 speed: 8-s maps take 32 s, a reduce about 6 min) is fixed by backup tasks once a phase has no idle tasks left, for ≤ 3% extra compute, and the job ends near 9.5 min instead of ≈ 12.5. A hot key (100 M inlinks, 10 GB, 40× the average partition) is deterministic, so backups and a bigger R both fail; we salt it into 64 sub-keys of about 156 MB, which readers treat as one list. A bad record that crashes the parser is skipped after 2 failed attempts, and the job fails past 1,000 skips.

Interviewer: "Your status page shows the inlinks job at 99% for six minutes. What's going on?"

You: "Three different diseases share that symptom, and they need three different cures. Either a machine is slow, or one partition is enormous, or one record kills every attempt. The first move is diagnosis, because the cure for one does nothing for the others."

Diagnosis First: Is It the Machine or the Key?

Flowchart for diagnosing a task still running near phase end: a second attempt shows whether other tasks on that machine are also slow (straggler machine w-1555, so run a backup task on a healthy machine and let the first finisher win while the other is killed), whether the partition is 40x the average size (a skewed hot-key partition, where a backup would redo the same 10 GB, so salt the key into 64 sub-keys and have readers treat the 64 partials as one list), or whether the same record crashes every attempt (a bad record, skipped after 2 failures).

The test is simple: does the slowness follow the machine or the work? Move a straggler's task to a healthy machine and it runs at normal speed. Move a hot key's task and it is just as slow, because the work is the problem.

Sign in to continue reading

The rest of this lesson is available with a free account. Signing in with Google or Microsoft is free.

Sign in to read the full lesson

Sign in to MAANG.io

Use your Google or Microsoft account — no password to remember.

Continue with Google Continue with Microsoft

Please accept the terms above to continue.