interviewpath
  • 0day streak
  • 10total XP
  • Level 1
0/6

Unit 6 · Databases · Lesson 10 of 10

Database benchmark and workload design

Database performance numbers mean something only relative to a workload, a configuration and a measurement method. This topic covers designing and running benchmarks with realistic skew, concurrency and cache state, verifying that results are correct and reproducible, and recognizing what standard suites measure.
About 3 hFocus mode

Step 1: Learn the ideas

  • Benchmark questions: throughput, latency percentiles, scalability, cost
  • Workload mix, data generation and scale factors
  • Key distributions: uniform, Zipfian, latest; hot keys and contention
  • Load generation: closed versus open loop, coordinated omission
  • Cache state: cold, warm and steady state; warm-up and run length
  • Configuration fairness: durability, isolation level, tuning effort, versions
  • Correctness checks and result validation
  • Reproducibility: scripts, versions, hardware, seeds, raw data
  • Standard suites at awareness level: TPC-C, TPC-H, TPC-DS, YCSB, JOB, pgbench

Why it matters

Claims like "X is ten times faster than Y" are easy to produce and hard to trust. Database performance depends on data size relative to memory, key skew, concurrency, durability settings and tuning. Research papers, vendor comparisons and your own engineering decisions all need workloads that answer a specific question and measurements others can repeat.

Core ideas

Start from the question. "Does the new index speed up checkout?" needs the checkout transaction mix at production-like data size and concurrency, not a generic suite. Fix the metric before running anything: throughput at a latency target, p99 latency, or cost per query.

Skew. Real access patterns are rarely uniform. Under a Zipfian distribution the k-th most popular key is requested with probability proportional to 1/k^s, so a few keys dominate. Skew raises cache hit rates (good for reads) and contention on hot rows (bad for writes). Test both uniform and skewed distributions; YCSB and pgbench can generate Zipfian keys.

Load generation. Sweep the number of clients to find the knee where latency rises sharply. Closed-loop clients wait for each response before sending the next request, so they slow down exactly when the system does and hide queueing delay; measuring latency from the intended send time avoids this coordinated omission. Check that the client machine is not the bottleneck.

Cache and steady state. Cold runs measure I/O paths; warm runs measure in-memory behavior. LSM engines need time for compaction to reach steady state, and MVCC systems accumulate old versions. Report warm-up, run length, repetitions and spread, and use percentiles for latency.

Correctness and fairness. Verify results (row counts, checksums, invariants such as total balance) so a misconfigured system cannot win by doing less work. Compare systems at equivalent durability (same flush policy) and isolation, with comparable tuning effort, and record versions, configuration, hardware and generator seeds.

Standard suites. TPC-C models order-entry OLTP with several transaction types and contention on warehouse and district rows. TPC-H is a decision-support suite whose generated data is mostly uniform and independent. TPC-DS adds more complex queries and skewed data. YCSB defines key-value workloads with configurable read/update mixes and request distributions. JOB uses real, correlated IMDB data to stress join ordering. Official TPC results follow audited rules; informal "TPC-H-like" runs do not.

Common misconceptions

  • "Averages summarize latency." Tails matter; report percentiles and their variation across runs.
  • "A standard benchmark answers my question." It answers its own question; check whether its mix, size and skew resemble yours.
  • "Default configurations make a fair comparison." Defaults differ in durability and memory use; state and justify settings.
  • "One run is enough." Caches, background work and noise require repetitions and a measure of spread.
  • "Faster means better." Without correctness checks a fast run may be skipping work or returning wrong results.

How to approach it

Read "Fair Benchmarking Considered Difficult" for a catalog of pitfalls, then run a small study: pgbench or YCSB with uniform versus Zipfian keys, cold versus warm cache and three client counts, five repetitions each. Write a one-page report that someone else could reproduce from your scripts.

Suggested order

  1. 1Read “Fair Benchmarking Considered Difficult” and turn its pitfalls into a checklist.
  2. 2Read the TPC-C and TPC-H overview pages and the YCSB Core Workloads wiki page; note what each workload stresses.
  3. 3Read the PostgreSQL pgbench page, including custom scripts and its random-distribution functions.
  4. 4Skim the BenchBase repository to see how a multi-workload OLTP harness controls rates and mixes.
  5. 5Run the skew, cache and concurrency study and write the reproducible report.

Step 2: Check off what you can do

Tap each one you can genuinely do or explain. Each earns 10 XP.

Step 3: Go deeper

  • Fair Benchmarking Considered Difficult: Common Pitfalls In Database Performance TestingStart here

    Hannes Mühleisen (author-hosted PDF)

    A compact catalog of database benchmarking pitfalls with a checklist to apply to your own runs.

    Open(opens in a new tab)Link responded, 5 Oct 2026
  • Transaction Processing Performance Council (TPC) benchmarks

    TPC

    Section: TPC-C

    What the standard OLTP benchmark models and how official results are reported; see TPC-H and TPC-DS for decision support.

    Open(opens in a new tab)Link responded, 5 Oct 2026
  • YCSB: Yahoo! Cloud Serving BenchmarkStart here

    GitHub (YCSB project)

    Section: Core Workloads (wiki)

    Standard key-value workload mixes and request distributions for controlled skew experiments.

    Open(opens in a new tab)Link responded, 5 Oct 2026
  • PostgreSQL documentation (current release)

    PostgreSQL Global Development Group

    Section: pgbench

    Built-in PostgreSQL benchmarking tool: default script, custom scripts, Zipfian random keys, latency reporting.

    Open(opens in a new tab)Link responded, 5 Oct 2026
  • BenchBase: multi-DBMS SQL benchmarking framework

    GitHub (CMU Database Group)

    Ready-made OLTP workloads (including TPC-C and YCSB) for relational databases with rate and mix control.

    Open(opens in a new tab)Link responded, 5 Oct 2026

Step 4: Practice

Run the skew, cache and concurrency study on a local PostgreSQL (pgbench with a custom Zipfian script) or with YCSB against any store. For each configuration record throughput, p50/p95/p99 latency, repetitions and spread, and a correctness check such as a balance invariant. Restart the server and drop the OS cache for cold runs where your operating system allows it, and document exactly how you did it. If you build the toy LSM store, benchmark it with the same discipline.

Record attempts on each problem’s page (+15 XP, +10 more when solved on your own).

Step 5: Test yourself

Answer each one out loud or on paper before you finish the lesson.

  1. Question 1Why does Zipfian skew help read throughput but hurt write-heavy workloads?
  2. Question 2What is coordinated omission, and how does it distort latency percentiles?
  3. Question 3How do you decide that a system has reached steady state?
  4. Question 4Which durability settings must match before comparing two databases?
  5. Question 5What correctness check would you add to a TPC-C-like run?

You’re done when you can

  • Design a benchmark plan for a stated question, including metric, workload, distributions, concurrency sweep and correctness check.
  • Run a study comparing uniform and Zipfian keys and cold and warm caches with repetitions, and explain the differences.
  • Name three fairness pitfalls in a published comparison and how you would fix them.
  • Explain what TPC-C, TPC-H, YCSB and JOB each measure in one sentence each.

Finish the lesson

How confident do you feel?

Lesson complete!

+50 XP

Reviews will come up on the Practice tab so it sticks.

Unlocks next: Database workload evaluation

Your notes and study time

Log study time