I recently set up an lnmp on my desktop. I want to press the lnmp to see how it works. Nginx is only a static web server with high concurrency. Therefore, the performance bottleneck of lnmp lies in the processing capacity of php, that is, php-fpm. Hardware CPUAMDPhenom (tm) IIX4945 memory 4Gx4
I recently set up an lnmp on my desktop. I want to press the lnmp to see how it works.
Nginx is only a static web server with high concurrency. Therefore, the performance bottleneck of lnmp lies in the processing capacity of php, that is, php-fpm.
Hardware
-
Cpu amd Phenom (tm) II X4 945
-
Memory 4 GB x 4
-
Hard Drive west green disk 7200 rpm
-
Nic realtek 8169 Gigabit adaptive
Software version
-
Nginx 1.4.0
-
Mysql 5.5.31
-
Php 5.4.14
The re-compiled rpm Package has
-
Nginx
-
Mysql
-
Php
-
Php-pecl-zendopcache
-
Libevent
Lnmp optimization methods mainly include:
| 12345678 |
Kernel parameter file handle count php Cache nginx compilation nginx pagespeednginx cache nginx compression nginx CPU binding |
Use autoscaling to simulate 300 to 1000 concurrency. each concurrency lasts for 2 minutes, and then the concurrency increases by 100. each connection has five requests.
Command
-
Autoscaling -- single_host -- host1 192.168.1.101 -- port1 80 -- uri1/phpinfo. php -- low_rate 300 -- high_rate 1000 -- rate_step 100 -- num_call 5 -- const_test_time 120 -- timeout 2 -- file result. tsv
Result
| |
Connection count request speed req/s connection speed conn/s total number of connections 300 291.4 287.9 1500400 374.4 383.9 2000500 384 394.3 2500600 389.9 399.2 3000700 385.7 397.2 3500800 390.8 399.7 4000900 389.3 399.1 45001000 379.8 391.9 5000 |
Result analysis,
When concurrency started at 300, php's processing capability gradually increased, reaching its highest peak of 390.8req/s at 800, and then gradually declined. it can be seen that php's overall processing request capability was around 380 per second, theoretically, the total traffic is about 380 million (32832000x60x60x24 = ).
Based on the 80% principle, 20% of requests are completed in 20% of the time period, 4.8 of the time is 6.5 million hours, and the number of requests that can be tolerated is 380 (4.8x60x60x6566400 = ), the actual total traffic is 8.2 million (6566400/0. 8 = 8208000 ).
According to Daniel Zhang's blog, he can achieve 700req/s (theoretically equivalent to 6 million daily visits), but he compiles the whole process, and here I use rpm for the whole process, only some core software packages are re-compiled by srpm, and the hardware is just a common desktop.
In short, there is still a lot of optimization space to continue!