Service performance indicators: PV, UV, TPS, QPS

Glossary

PV

  Page View, page views. The number of pages to be invoked readers to browse. Web page every time you open or refresh the page, recorded once. Multiple users access the same page, visit the cumulative amount.

UV

  Unique Visitor, unique visitors. It refers to access through the Internet, browse individuals this page. Within a certain period of time, the number of different visitors to access the site, and each visitor only be counted once. With a client's computer, 00: 00 ~ 24: 00 pages visited many times, only counted once. For example, suppose a user visited three times on Wednesday, Thursday visited 1 times, once on Wednesday recorded as PV, Thursday also referred to as 1 PV. Generally calculated by Cookies.

TPS

  Transactions Per Second (processing of the number of things transmitted per second), i.e., the number of transactions per second server process. PS comprises a message into a message and a plus one user to access the database.

QPS(或RPS Request Per Second)

  Queries Per Second. Queries per second rate. Within the specified time the measure of how much traffic processing.
  Corresponds fetches / sec, i.e., in response to requests per second, that is, the maximum throughput.

QPS = number of concurrent / average response time

Factors affecting the performance of server systems

Measure service performance, there are two:

  • QPS (Query Per Second, the number of requests per second)
  • Response time (Response Time, RT), it will be appreciated that the server response time consuming process.

Under normal circumstances, the response time is shorter, the higher the QPS. In the case of single-threaded, is linear. But not grow indefinitely, RT there are always limits.

Multi-threaded, the total QPS = (1000ms / response time) * number of threads.

Response relationship between time and the QPS

For the Web system, typically by the response time of CPU processing time and the waiting time for a thread components.

By reducing the thread waiting time for the performance of the system upgrade is not great. Real effect on performance is the execution time of the CPU.

After the actual test, it is reduced by half if the execution time of CPU, you can increase the QPS doubled.

The impact on the number of threads of QPS

According to the formula 总QPS = (1000ms/ 响应时间)* 线程数, the intuition, the higher the increase in the number of threads QPS. In fact, the number of threads is not better. Because the thread itself is resource-intensive, but also by other factors. For example, a thread switching the multithreaded system cost will be higher, and each thread will also spend a certain memory. (Single-threaded language, even create multiple instances on a single server, the server itself may be restricted resources. For example, nodeJS can use PM2, start multiple threads on a single server, but the server itself limited resources. )

How to set a reasonable number of threads

So how do you set the thread count on the server do? General formula is as follows:

Threads Number = 2 * CPU core + 1

Best Practice formula:

Threads = [(thread thread CPU time latency +) / thread CPU time] × Number of CPU

Of course, the best way is to find the optimum number of threads system performance test.

How to find bottlenecks

We can monitor tool system, found that the performance bottleneck of the system. Where performance bottlenecks usually occur a CPU, memory, disk, network, database, and so on.

Frequently, the cache system where bottlenecks are likely to occur memory storage systems is the I / O.

How short answer to determine whether a CPU bottleneck occurs? We can observe, when the QPS limit is reached, the server's CPU usage is not more than 95%, if not exceeded, indicates that the CPU still room for improvement.

Performance optimization process

  1. Find short board.
  2. Reduce data. In fact, there are two places in particular affect performance. First, the server inevitably exist in the processing of data characters into bytes into each other, the second is to do Gzip compression HTTP request, as well as time-consuming network transmission, which are closely related and data size.
  3. Data classification. The first screen of data, important information first, secondary information asynchronous loading.
  4. Reduce intermediate links.

Report: Performance Testing Index

Complicated by Response time The application server cpu The database server cpu TPS
50 1s 50% 20% 50

 

Pressure measurement tools: stresstester

pom.xml file package introduced

<dependency>
    <groupId>com.taobao.stresstester</groupId>
    <artifactId>stresstester</artifactId>
    <version>1.0</version>
</dependency>

Write test code:

/ ** 
* @Title: PressTest 
* @Description: Stress Test, test method for acquiring user information of QPS 
* @param parameter 
* @return void return type 
* @throws 
* / 
@Test 
public  void PressTest () {
     int concurrencyLevel = 100; // number of concurrent 
    int totalRequest = 1000; // total number of requests 
    StressResult StressTestUtils.test Result = (concurrencyLevel, totalRequest, new new StressTask () { 
      @Override 
      public Object doTask () throws Exception { 
         getUserDetail (); 
         return ""; 
      }
  });
    System.out.println(StressTestUtils.format(result));
}

Test Results:

  The figure test results it is clear that there is a problem, so long request for three seconds, and this is not acceptable, by analyzing, positioning the connection pool is set too small, the database connection is too small, complicated by excessive, leading to a request block waiting for resources, optimization approach: increase the number of threads in the connection pool, increase the number of database connections


Information: https: //mp.weixin.qq.com/s/4pjydskyaBqyjk0TDNtSVA
      https://www.jianshu.com/p/f38b3876f522

  

Guess you like

Origin www.cnblogs.com/myseries/p/11227574.html