Terminology (6)Terms used in this lesson
Term on the front, definition on the back. Paste with tabs between fields and a new line between cards, or import the download in Anki as Basic.
- Distribution
- How often each value occurs. A histogram groups values and counts each group.
- Long tail
- A few values far larger than the typical one. They can dominate totals while barely affecting counts.
- Grouped data
- Values recorded as (value, count) pairs instead of one entry per observation.
- Share of count
- What fraction of observations fall in a range.
- Share of total
- What fraction of the summed quantity, such as compute minutes, those observations carry.
- Cohort
- A subgroup such as a team, region or client version whose contribution you want to see separately.
Why this matters
Job durations, request sizes, customer spend and file sizes are usually long-tailed: most values are small and a few are huge. Capacity is consumed by totals, so the few can decide the bill and the queue while barely registering in counts or medians. Systems also store these values as histograms, so the arithmetic has to work on grouped data.
This lesson assumes means, medians and percentiles from the previous lesson.
What a distribution preserves
A distribution describes how observations are spread across values. A histogram groups them and records how many fall in each group. The examples here group exact durations; ordinary interval buckets would leave each job’s precise duration unknown. A long tail contains relatively few large values that can contribute much of the total.
The means, medians and percentiles from the previous lesson summarize different parts of that distribution. To discuss capacity, also name the resource unit: under this lesson’s one-identical-worker-per-job assumption, duration times job count gives worker-minutes. A share of jobs uses a count denominator; a share of work uses a resource denominator. Neither share alone determines how many workers are needed.
01Read a histogram
Read a histogram
Only 5% of yesterday’s batch jobs ran 10 minutes or longer, so a separate pool for them sounds wasteful. Those jobs used 64% of all compute minutes, and nearly all of that came from one team.
The pool investigation needs worker occupancy, not just a count of requests. Assume each job holds one identical worker for its whole duration; job minutes then add as worker-minutes. These groups record exact durations, rather than intervals with unknown values inside. Yesterday’s batch jobs, grouped by duration: 950 took 2 minutes, 40 took 10 and 10 took 300. That is 1,000 jobs and 5,300 minutes. Predict the three lines this program prints.
// [minutes, jobs] for one day of batch jobs
const groups: [number, number][] = [
[2, 950],
[10, 40],
[300, 10]
];
const jobs = groups.reduce((sum, [, count]) => sum + count, 0);
const minutes = groups.reduce((sum, [value, count]) => sum + value * count, 0);
const longMinutes = groups.reduce(
(sum, [value, count]) => (value >= 10 ? sum + value * count : sum),
0
);
console.log((minutes / jobs).toFixed(2)); // mean
const longJobs = groups.reduce(
(sum, [value, count]) => (value >= 10 ? sum + count : sum),
0
);
console.log((longJobs / jobs).toFixed(4)); // share of jobs taking 10 minutes or more
console.log((longMinutes / minutes).toFixed(4)); // share of minutes they use
Grouped data fits in an array of [value, count] tuples. Sort with a comparator on the value, (a, b) => a[0] - b[0], before walking it for a median.
03Same mean, different shape
Same mean, different shape
A mean describes the total, not the shape. Report the median and a tail measure beside it, or show the histogram.
04Split by cohort
Split by cohort
Two teams sent the jobs. Search sent 900 jobs of 2 minutes and the 10 of 300; Ads sent 50 of 2 minutes and the 40 of 10. The long jobs used 3,400 minutes in total: 3,000 from Search (88.2%) and 400 from Ads (11.8%).
05Empty windows
Empty windows
06Size the long-job pool
Size the long-job pool
The platform team needs to know whether the long-job work is concentrated enough to investigate a separate pool. Repair its grouped summary, separate job counts from worker-minutes, then attribute the pooled tail to teams. A correct per-team tail percentage can still answer the wrong capacity question.
Batch job durations
Summarize the jobs, measure the tail, then find who sends it.
In the frontend Count share and time share in Next.js and Svelte Optional
The buckets partition the window’s jobs; each minutes field is its bucket’s total worker-minutes. A jobs dashboard puts the long bucket’s share of jobs and share of time in one sentence, so nobody reads 5% as the cost. A zero-minute window still has a job share; it has no time share. A missing bucket is a separate unavailable-data state.
type Bucket = { label: string; jobs: number; minutes: number };
// The long bucket's share of jobs and its share of compute time, side by side.
export function LongJobs({ buckets, long }: { buckets: Bucket[]; long: string }) {
const jobs = buckets.reduce((sum, b) => sum + b.jobs, 0);
const minutes = buckets.reduce((sum, b) => sum + b.minutes, 0);
const bucket = buckets.find((b) => b.label === long);
if (jobs === 0) return <p>No jobs in this window.</p>;
if (!bucket) return <p>Long-job bucket unavailable.</p>;
return (
<p>
Jobs in {long}: {((100 * bucket.jobs) / jobs).toFixed(1)}% of jobs,{" "}
{minutes === 0
? "time share unavailable"
: `${((100 * bucket.minutes) / minutes).toFixed(1)}% of compute time`}
</p>
);
}
See Svelte $derived.
Check this idea later
Sources
Values above were computed in Node 22 and run in Go 1.27, Rust 1.99 and Apple clang 17. The batch jobs are a worked model.
Sign in to keep your read marks on every device. Sign in
Was this helpful?