QPS query per second

QPS: Queries Per Second indicates the number of Queries a server can perform Per Second. It is a measure of the traffic processed by a specific query server within a specified period of time. On the Internet, the performance of a machine that serves as a DNS server is often measured by the query rate per second.

TPS transactions per second

TPS: short for TransactionsPerSecond, TransactionsPerSecond. It is a unit of measurement for software test results. A transaction is the process by which a client sends a request to the server and the server responds. The client starts the timer when it sends a request and ends it when it receives a response from the server to count the time used and the number of transactions completed. QPS vs TPS: QPS is basically similar to TPS, except that one visit to a page forms a TPS; However, a page request may result in multiple requests to the server, and the server can count these requests into the “QPS”. For example, accessing a page will request the server twice, and one visit will generate a “T” and two “Q”.

RT response time

Response time: The total time it takes to execute a request from the beginning to receive the response data at the end, i.e. from the time the client initiates the request to the time 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.

Four, the number of concurrent

Concurrency refers to the number of requests a system can handle at the same time, which also reflects the load capacity of the system.

V. Throughput

The throughput of the system (bearing capacity) is closely related to request CPU consumption, external interfaces, IO, and so on. The higher the CPU consumption of a single request is, the slower the external system interface and I/O speed is, and the lower the system throughput is. System throughput several important parameters: QPS (TPS), concurrency, response time.

QPS (TPS) : Number of requests/transactions Per Second Number of concurrent requests/transactions processed by the system Response time: Average response time After understanding the meanings of the above three elements, you can calculate the relationship between them:

QPS (TPS) = Number of Concurrent requests/Average response time Number of concurrent requests = QPS x Average response time

Six, practical examples

Let’s use an example to connect the above concepts. According to the 80/20 rule, if 80% of the daily visits are concentrated in 20% of the time, that 20% of the time is called peak time.

Formula :(total PV * 80%)/(seconds per day * 20%) = peak time requests per second (QPS)

Machines: Peak time QPS per second/QPS per machine = required machines

1. How much QPS is required for a single machine with 300W PV per day? (3000000 * 0.8)/(86400 * 0.2) = 139 (QPS)

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

7. Optimal number of threads, QPS, RT

1. Single-thread QPS formula: QPS=1000ms/RT

For the same system, the more threads supported, the higher the QPS. Assuming an RT is 80ms, QPS can be easily calculated,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 whole system is 2* (1000/80) = 25. It can be seen that QPS increases linearly with the increase of threads. That QPS can not add thread bai, sounds very reasonable, the company also said, but often the reality is not so.

2. The real relationship between QPS and RT

We imagine the relationship between QPS and RT as follows

The actual RELATIONSHIP between QPS and RT is as follows

3. Optimal number of threads

The critical number of threads that just consume the server’s bottleneck resources is expressed as follows

Optimal number of threads = ((thread wait time + thread CPU time)/thread CPU time) * number of cpus

Features:

When the optimal number of threads is reached, the number of threads continues to increase, the QPS will remain unchanged, while the response time becomes longer, and the number of threads continues to increase, the QPS will begin to decrease. Each system has an optimal number of threads, but the optimal number of threads varies from state to state. Bottleneck resources can be CPU, memory, lock resources, IO resources: exceeding the optimal number of threads – resulting in resource contention, exceeding the optimal number of threads – increasing response time.

Concern public number: Java baodian