current position:Home>Performance indicators: QPS, TPS, RT, throughput

Performance indicators: QPS, TPS, RT, throughput

2022-11-24 23:09:58code bandits

1. QPS query per second

QPS: Queries Per Second means "query rate per second", which is the number of queries that a server can per second, and is the traffic processed by a specific query server within a specified timeHow much to measure.On the Internet, the performance of a machine serving as a Domain Name System server is often measured in terms of queries per second.

Second, TPS transactions per second

TPS: It is the abbreviation of TransactionsPerSecond, that is, transactions/second.It is a unit of measurement for software testing results.A transaction is a process in which a client sends a request to a server and the server responds.The client starts timing when it sends a request, and ends timing after receiving the server's response, so as to calculate the time used and the number of completed transactions.QPS vs TPS: QPS is basically similar to TPS, but the difference is that one visit to a page forms one TPS; but one page request may generate multiple requests to the server, and the server can count these requests into "QPS".For example, accessing a page will request the server twice, and one access will generate one "T" and two "Q".

3. RT response time

Response time: The overall time it takes to execute a request from the beginning to the end when receiving the response data, that is, the time from when the client initiates the request to when the server responds.Response time RT (Response-time) is one of the most important indicators of a system, and its value directly reflects the speed of the system.

4. Concurrency

The number of concurrency refers to the number of requests that the system can handle at the same time, which also reflects the load capacity of the system.

5. Throughput

Throughput:It is the ratio of the CPU time spent running user code to the total CPU time consumed.
The throughput (pressure bearing capacity) of the system is closely related to the CPU consumption, external interface, IO, etc. of the request.The higher the CPU consumption of a single request, the slower the external system interface and IO speed, the lower the system throughput, and vice versa.Several important parameters of system throughput: QPS (TPS), concurrent number, response time.

QPS (TPS): (Query Per Second) Number of requests/transactions per second Concurrent number: Number of requests/transactions processed by the system at the same time Response time: Generally take the average response time After understanding the meaning of the above three elements, you canCan deduce the relationship between them:

QPS (TPS) = Concurrent Number/Average Response Time Concurrent Number = QPS*Average Response Time

6. Practical examples

We use an example to understand the above concepts together.According to the 80/20 rule, if 80% of daily visits are concentrated in 20% of the time, this 20% time is called the peak time.

Formula: (total PV number * 80% ) / (number of seconds per day * 20% ) = peak time requests per second (QPS)
machine: peak time QPS per second / QPS of a single machine = required1. 300w PV per day on a single machine, how many QPS does this machine need?( 3000000 * 0.8 ) / (86400 * 0.2 ) = 139 (QPS)

2. If the QPS of a machine is 58, how many machines are needed to support it?139 / 58 = 3

Seven, optimal number of threads, QPS, RT

1. Single-threaded QPS formula: QPS=1000ms/RT
For the same system, the more threads it supports, the higher the QPS.Assuming that an RT is 80ms, you can easily calculate QPS, QPS = 1000/80 = 12.5 multi-threaded scenario, if the number of threads on the server is increased to 2, then the QPS of the entire system is 2*(1000/80)= 25, it can be seen that QPS increases linearly with the increase of threads, so if QPS does not increase, add threads. It sounds reasonable, and the company also makes sense, but it is often not the case in reality.

2. The real relationship between QPS and RT
The relationship between QPS and RT we imagine is as follows
Insert image description here

The actual relationship between QPS and RT is as follows
Insert picture description here
3, optimal number of threads
The critical number of threads that just consume the bottleneck resources of the server, the formula is as follows

Optimal number of threads = ((thread waiting time + thread cpu time)/thread cpu time) * number of cpus
Features:
When the number of threads reaches the optimal number, the number of threads continues to increase, then QPSremains unchanged, but the response time becomes longer and the number of threads continues to increase, the QPS begins to decline.Each system has its optimal number of threads, but in different states, the optimal number of threads will change.Bottleneck resources can be CPU, memory, lock resources, and IO resources: Exceeding the optimal number of threads leads to resource competition, exceeding the optimal number of threads - increasing response time.

copyright notice
author[code bandits],Please bring the original link to reprint, thank you.
https://en.chowdera.com/2022/328/202211242256490440.html

Random recommended