Queries per second
easy 30 minQPS is how many queries arrive, or can be answered, each second.
Video lesson · Chapter 1 of 6
From users to a rate
From a day to a second
1:10Reel coming soon
Theory
Read or listen first. About 1 min.
What it is
QPS, queries per second, is a rate: the number of queries divided by the seconds in which they came. 600 questions in one minute are 10 QPS.
The word has two uses. Load is the QPS that arrives. Capacity is the QPS a system can answer while still meeting its latency target. A design is fine as long as load stays well below capacity, also in the busiest minute.
Why it exists
Products are described in people and days: a million users, twenty views each. Machines are described in seconds. QPS is the bridge between the two.
It is the first number in most design interviews, because it decides early whether one database is enough, whether reads need a cache and whether writes must be split.
A short history
1909
A. K. Erlang publishes a first work on telephone calls as random arrivals. Telephone engineers plan for the busiest hour, not for the average.
1985
A paper in Datamation, prepared by Jim Gray and colleagues, proposes a common way to measure transactions per second.
1988
The Transaction Processing Performance Council is founded and turns that idea into audited benchmarks.
2012
Prometheus is started at SoundCloud. Its counters and
rate()function later become a usual way to graph requests per second.2024
Amazon reports that DynamoDB peaked at 146 million requests per second during Prime Day.
Words to know
- Average QPS
- Queries in a day divided by 86,400.
- Peak QPS
- The rate in the busiest time. We plan with three times the average.
- Spike
- A short jump far above the usual peak.
- RPS
- Requests per second, usually HTTP requests.
- TPS
- Transactions per second.
- Read to write ratio
- How many reads come with each write, such as 100:1.
- Headroom
- Capacity kept free for bumps and failures.
How it works
Step through the idea, or press Play.
Average. Daily total / 100,000
Understand it
Start here
The zoo information desk
Imagine the information desk at a zoo. Visitors ask, "Where are the penguins?" The clerk answers. The number of questions answered in each minute is the desk's rate. Computers are quicker, so for them we count each second.
8 / (6 × 0.7) = 1.9, so 2 clerks, and 1 spare makes 3.
Words
QPS, RPS and TPS
| Counts | Common for | |
|---|---|---|
| QPS, queries | One question to a system: a search, a SQL statement, a cache lookup | Search engines, databases, caches |
| RPS, requests | All HTTP requests, reading and writing | Web servers, APIs, load balancers |
| TPS, transactions | All-or-nothing units, each perhaps several queries | Payments, banking, order systems |
The rate changes on the way
One request, several queries
Why
Why it matters
Load below capacity
- Answers stay fast
- Users see results at once
- Bumps are absorbed
- No queues, no timeouts
Load above capacity
- Requests pile up in queues
- Latency climbs steeply
- Timeouts and errors, then retries
- The system may stop answering
Calculate
Three formulas
Basic, and from daily users
Peak
Quick reference
| Per day | Average, exact | In your head (/ 100,000) | Peak, × 3 |
|---|---|---|---|
| 1 million | 11.6/s | 10/s | 30/s |
| 100 million | 1,157/s | 1,000/s | 3,000/s |
| 1 billion | 11,574/s | 10,000/s | 30,000/s |
| 10 billion | 115,741/s | 100,000/s | 300,000/s |
Worked examples
Two sums from start to decision
A short-message service
| Step | Sum | Result |
|---|---|---|
| Daily users | assumed | 100 million |
| Queries each | assumed | 50 |
| Per day | 100M × 50 | 5 billion |
| Average | 5 billion / 86,400 | 57,870/s (50,000 in your head) |
| Peak | × 3 | about 174,000/s (150,000) |
| So | 17 times one database's planning line | reads from cache, data split |
A URL shortener
| Step | Sum | Result |
|---|---|---|
| New links | 10 million a day / 86,400 | 116 writes/s |
| Reads | 100 for each write | 11,574/s |
| Together | 116 + 11,574 | 11,690/s average |
| Peak | × 3 | about 350 writes/s and 35,000 reads/s |
| So | writes are easy, reads are not | one database for writes, a cache for reads |
From users to a decision
Distribution
Traffic is not flat
A school cafeteria sees 5 children at 9 and 500 at noon. The average is 50 an hour, and nobody is helped by that number at noon.
load = {0: 20, 2: 10, 4: 8, 6: 15, 8: 45, 10: 70, 12: 85, 14: 75, 16: 65, 18: 80, 20: 100, 22: 55}for hour, v in load.items(): mark = "peak" if v > 80 else "moderate" if v > 50 else "low" print(f"{hour:02d}:00 {'#' * (v // 4):25s} {v:3d} {mark}")avg = sum(load.values()) / len(load)print(f"average {avg:.0f}, peak / average {max(load.values()) / avg:.1f}")# three regions, eight hours apart: the sum is much flatterv = list(load.values())world = [v[i] + v[(i + 4) % 12] + v[(i + 8) % 12] for i in range(12)]print(f"world: peak / average {max(world) / (sum(world) / 12):.2f}")Average, peak, spike
| Example | What to do with it | |
|---|---|---|
| Average | 1,000/s | Cost and storage |
| Peak, 2 to 3 times | 3,000/s | Normal capacity |
| Spike, 10 times or more | 10,000/s and up | Protect: cache, queue, waiting room, limits |
Four traffic patterns (the ratios are rules of thumb)
Day and night
Peak in office hours. Business tools. 2 to 3 times.
Evening
Peak after work. Streaming, games, social. 3 to 5 times.
Weekly
Weekend differs from weekday. Shops, travel. 2 to 4 times.
Events
News, live sport, flash sales. 10 to 100 times, at once.
Which peak do I use?
Geography
Follow the sun
Three regions, three evenings
When each region has the daily curve above, eight hours apart, the world peaks at only 1.2 times its average. But users go to the region near them, so each region still needs its own peak: 1.9 times. Size regions, not the world.
Capacity
How many servers?
For a birthday party with 20 invited children you prepare 30 bags, because some bring a brother, and you keep a room free in case it rains. That is headroom.
Machines
An online shop
| Step | Sum | Result |
|---|---|---|
| Per day | 10M users × 20 pages × 5 calls | 1 billion |
| Average | 1 billion / 86,400 | 11,574/s |
| Peak | × 3 | 34,722/s |
| Needed at 70% | 34,722 / 0.7 | 49,603/s of capacity |
| Servers at 1,000/s each | ⌈49.6⌉ + 1 | 51 |
| With a 2x buffer instead | 34,722 × 2 / 1,000 | about 70 |
Scale
Raising QPS
Out: more servers
- Close to linear for stateless servers
- Good for APIs
- Needs load balancing
- Survives losing one
Up: a bigger server
- Faster CPU, more RAM, SSD
- Limited by the largest machine
- Good for databases
- Still one thing that can fail: see vertical scaling
Quick wins, and how to work out the gain
| Move | Gain | Why |
|---|---|---|
| Caching | 1 / (1 - hit rate): 10x at 90%, 100x at 99% | Only misses reach the store |
| Connection pool | (open + query) / query | Large if opening is slow |
| Query optimisation | Time before / time after | An index can turn seconds into milliseconds |
| Read replicas | Up to the number of copies, for reads only | Every write still goes to every copy |
Peak is above one machine. What now?
Real sizes
What is large?
Published by the owners
| System | Published | Per second |
|---|---|---|
| Google Search (2025) | More than 5 trillion searches a year | about 158,000 average |
| Amazon DynamoDB, Prime Day 2024 | 146 million requests a second | peak |
| Amazon ElastiCache, Prime Day 2024 | Over 1 trillion requests a minute | about 17 billion at peak |
One node, to plan with
| System | Simple operations | Remember |
|---|---|---|
| MySQL or PostgreSQL | 10,000/s as a planning line | A heavy query can use a whole core; a tuned machine goes further |
| Redis | 100,000/s | The docs show a benchmark near 180,000 |
| MongoDB, Cassandra | No single number | Documents, nodes, replicas and consistency change it |
| Elasticsearch | Far fewer: each search does more work | Depends on index size and the query |
Interview
Do and avoid
Do
- Work QPS out from the requirements
- Split reads and writes
- Use a peak of 3 times
- Add headroom: 70% and a spare
- Mention a cache when reads repeat and the number asks for it
Avoid
- Skipping the sum when a decision waits for it
- Planning for the average
- Forgetting the read to write ratio
- Forgetting that the database is often the limit
Watch it live
Summary
The whole topic in one minute.
Average QPS is the daily total divided by 86,400, or 100,000 in your head. Multiply by three for an ordinary peak, and count people instead when a clock brings them together.
Split reads and writes, multiply by the queries each request makes, then divide the peak by 70% of what one tested machine can do, and add one spare.
- QPS = queries / seconds. A day is 86,400 s.
- Average × 3 is the peak; a clock-driven rush counts people.
- Reads and writes apart, and one request may be many queries.
- Machines: peak / (capacity × 0.7), rounded up, plus one.
- End with a decision.