Fundamentals 3 min read

Mastering TPS and QPS: Simple Calculations and Real-World Examples

This article explains the key performance metrics TPS (transactions per second) and QPS (queries per second), provides formulas for calculating them, and demonstrates practical calculations for multi-node deployments, illustrating how request latency, thread pools, and instance count affect overall system concurrency and throughput.

Lin is Dream
Lin is Dream
Lin is Dream
Mastering TPS and QPS: Simple Calculations and Real-World Examples

TPS (Transactions Per Second) and QPS (Queries Per Second) are important metrics for measuring system performance, commonly used to describe the throughput of high‑concurrency or distributed systems.

TPS Calculation

1. TPS (transactions per second) = number of requests per second.

2. Multi‑threaded requests = threads × TPS.

3. Concurrency = TPS × number of system instances.

Example (5 nodes, 2000 TPS)

Assume an interface average latency of 500 ms, so each request takes 0.5 s, giving 1/0.5 = 2 requests per second per thread. With a thread pool of 200 threads, each instance handles 200 × 2 = 400 TPS. Deploying 5 instances yields total concurrency 400 × 5 = 2000 TPS, i.e., 2 million requests per hour.

QPS Calculation

1. QPS (queries per second) = number of queries per second.

2. Multi‑threaded requests = threads × QPS.

3. Query volume = QPS × number of system instances.

Example (5 nodes, 6000 QPS)

Assume a query latency of 150 ms, so each thread can process 1/0.15 ≈ 6.67 queries per second. With 200 threads, each instance handles 6.67 × 200 ≈ 1334 QPS. With 5 instances, total concurrency is 1334 × 5 ≈ 6670 QPS, i.e., about 24 million queries per hour.

Observed production data: For a system handling millions of orders across 4 nodes, the per‑second order intake is around 20, CPU usage 10 %, memory unaffected, disk usage 50 %, and interface response time about 500 ms; slow SQL queries noticeably increase response time.

concurrencycapacity planningthroughputsystem performanceQPSTPS
Lin is Dream
Written by

Lin is Dream

Sharing Java developer knowledge, practical articles, and continuous insights into computer engineering.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.