Toolvito

Works on this device

Query Throughput Calculator

Work out the queries each second (QPS) a database handles from the queries in progress and their latency, the concurrency a target rate needs, how busy the workers are, or the rate from a count of queries. You type every figure; nothing is measured.

Enter your values

Little's law: queries in progress = queries each second × mean latency. So throughput = concurrency ÷ latency, and it works the other two ways.

Your values

The mean number of queries in progress at once: busy connections, threads or clients that wait for an answer.

The mean time from sending a query until its answer is back, waits in the database included.

Your values are worked out in this browser. They are not sent to a server.

Your result will show here

Fill in the values, then choose Calculate.

How to use this calculator

  1. Choose what you want to work out. Queries each second from concurrency and latency is the first choice.
  2. Type the figures from your monitoring: queries in progress, mean latency, a rate, or two readings of a counter.
  3. Choose Calculate. Each result shows the working with the exact numbers.

The formulas

  • Little's law: queries in progress = queries each second × mean latency. So QPS = concurrency ÷ latency, and concurrency = QPS × latency.
  • Utilisation: use of the workers = QPS × service time of one query ÷ workers. The most QPS at 100% use = workers ÷ service time.
  • Clients that pause: QPS = clients ÷ (latency + think time).
  • From a count: QPS = queries counted ÷ seconds. From a counter: (second reading − first reading) ÷ seconds between them.

Worked examples

Concurrency and latency: 32 queries in progress with a mean latency of 8 ms give 32 ÷ 0.008 = 4,000 queries each second.

Concurrency for a rate: 2,400 queries each second at 8 ms keep 2,400 × 0.008 = 19.2 queries in progress, so at least 20 connections.

Utilisation: 2,400 queries each second with a service time of 5 ms keep 12 workers busy. With 16 workers that is 75% use. At a target of 70%, 16 workers allow 16 ÷ 0.005 × 0.7 = 2,240 queries each second.

Counter: the counter read 1,048,576,000 and 60 seconds later 1,048,720,000. That is 144,000 queries in 60 s, or 2,400 each second.

Clients: 200 clients with a latency of 20 ms and a think time of 980 ms send 200 ÷ 1 s = 200 queries each second; on average 4 of them are in progress.

Other tools for the same subject

Limits you should know

  • These are averages over a steady period. The busiest second is higher, so keep room to spare.
  • Latency is not fixed: it rises as the database gets busier. A rate worked out at a low load may not hold at a high load.
  • The tool reads no database and runs no query. Every figure is the one you type.

Related tools