Skip to content
Notifications
Clear all

ELI5: What is a benchmark and how do I create one?

1 Posts
1 Users
0 Reactions
3 Views
(@crusty_pipeline)
Estimable Member
Joined: 2 months ago
Posts: 142
Topic starter   [#2740]

Alright, let's get this over with. You hear "benchmark" thrown around like it's a magic spell that makes your data platform respectable. It's not. It's a controlled, repeatable test to measure performance, usually to answer one question: "Does this thing do what the vendor says it does, under *my* conditions?"

Think of it like checking the gas mileage on a new truck. The sticker says 25 MPG, but you're hauling concrete blocks up a mountain, not cruising empty on the interstate. A benchmark is you loading it up with *your* concrete blocks (data volume, query patterns, concurrency) and driving up *your* mountain (your hardware, your network) to get a real number.

Creating one isn't about fancy tools. It's about discipline. Most people screw it up by testing with toy data on a quiet laptop. Here's the bare bones of how you do it right, assuming you're comparing two BI/database systems:

**1. Define the "So What?" Metric.** What actually matters to your business?
* Is it the 95th percentile query response time for dashboard loads?
* Is it the throughput (queries per hour) with 50 concurrent analysts?
* Is it the time to refresh a specific, gnarly materialized view overnight?
Pick ONE primary metric to optimize for. You can track others, but have one king.

**2. Recreate Your World (The Hard Part).** Your benchmark is useless if it doesn't mirror production.
* **Data Shape & Volume:** Don't use TPC-H unless your business is a textbook. Take a sanitized copy of your production schema and a representative slice of data (or full scale if you can). Cardinality matters.
* **Query Load:** Capture a day of real production queries from your logs. Not just the easy ones—include the ugly, multi-join, window-function monstrosity that finance runs every Monday.
* **Concurrency:** If you have 10 users, test with 10 simulated connections. If you have 1000, well, you'll need more hardware.

**3. Build a Harness (The Boring Part).** This is where people get distracted by shiny tools. A simple script that loops, connects, fires queries, and logs timestamps is often enough. Here's the spirit of it:

```python
import time
import psycopg2
import random

queries = [list_of_your_sql_strings]
conn = psycopg2.connect(your_dsn)
cursor = conn.cursor()

for i in range(num_iterations):
q = random.choice(queries) # Or follow a sequence
start = time.perf_counter()
cursor.execute(q)
# fetchall if needed
end = time.perf_counter()
log.write(f"{i},{q_hash},{end-start}n")

conn.close()
```

**4. Run, Reset, Repeat.** Run your harness against System A. Collect results. **Nuke and rebuild System A to a clean state.** Run the exact same harness against System B. Same hardware, same network, same OS tuning. Any variance? Run it three times and average.

**5. Analyze the Boring Numbers.** Look at your primary metric. Did System A's p95 latency beat System B by 200ms? Great. Now, **was that difference worth the cost and migration pain?** That's the real question.

The biggest mistake is benchmarking in a vacuum. The result isn't "Tool X is fast." The result is "Tool X returns our sales cohort query under 2 seconds at the 99th percentile, for $Y/month, which is 30% better than our current setup but requires re-writing our materialized views."

Anything less is just playing with toys and generating pretty graphs for management. Now go get your hands dirty.

-- old salt



   
Quote