High-performance server architecture
I searched for Seda and found this article "Analysis and Simulation of Seda performance optimization ".
For the number of threads. For a Web request, the code execution time is St (service time), and the IO wait time for reading files and network calls is wt (wait time ), if the number of CPUs is n and the number of cores is m, the number of threads Tc (thread count) is:
TC = N * m * (1 + WT/ST)
If there is only one single-core CPU, if the IO is 40 ms and the program execution takes 20 ms, the following execution sequence can be obtained.
Request1 is executed for 20 milliseconds and waits for 40 milliseconds. In this case, the CPU is idle.
Request2 then runs for 20 milliseconds and waits for 40 milliseconds. At this time, request1 still needs to wait for 20 milliseconds.
Request3 then runs for 20 milliseconds and waits for 40 milliseconds. At this time, request2 still needs to wait for 20 milliseconds, and request1 has been executed.
Request4 can reuse the request1 thread.
According to this formula, if one single-core CPU exists in the following three application scenarios:
S1: St = 10 wt = 0 Tc = 1
S2: St = 10 wt = 50 Tc = 6
S3: St = 10 wt = 100 Tc = 11
S1 is purely computation with no I/O and only consumes the CPU; S2 is access to local files, with disk I/O; S3 is a database call with network I/O.
If S1 accounts for 10% of the total number of requests, S2 accounts for 20%, and S3 accounts for 70%, what is the TC? If the percentage is per
TC = N * m * (1 + (WT1 * Per1 + WT2 * per2... WTN * Pern)/(ST1 * Per1 + st2 * per2... STN * Pern ))
That is
Total wait time/total execution time
In the preceding scenario, the formula is as follows:
TC = 1*1*(1 + 80/10) = 9
That is to say, it is appropriate to set nine threads. Correctly estimate each scenario and obtain data for each scenario. By analyzing the ratio of each scenario, we can calculate the theoretical value of the number of threads. Of course, we also need to measure three CPU indicators based on stress testing: CPU utilization, load average, and context switch rate.
.
For details about SEDA, study it later.
========================================================== ========================================
Performance-related articles:
LoadRunner uses ODBC to write MySQL scripts
Monitors the Linux resources of the server during stress testing of LoadRunner.
The stress test measures three CPU indicators: CPU utilization, load average, and context switch rate.
High-performance server architecture)
Conversion from PV to TPS and TPS fluctuation in website performance tests
Use gtmetrix to optimize your webpage (Integrating yslow and firebug functions)