服务器采购腾讯云S2系列,Intel Xeon E5-2680 v4(2.4 GHz),4核16G,内网带宽1.5Gbps,公网带宽5Mbps。
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 79
model name : Intel® Xeon® CPU E5-26xx v4
stepping : 1
microcode : 1
cpu MHz : 2399.996
cache size : 4096 KB
physical id : 0
siblings : 1
core id : 0
cpu cores : 1
apicid : 0
initial apicid : 0
fpu : yes
fpu_exception : yes
cpuid level : 13
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx lm constant_tsc rep_good unfair_spinlock eagerfpu pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch xsaveopt pti retpoline bmi1 avx2 bmi2 rdseed adx
bogomips : 4799.99
clflush size : 64
cache_alignment : 64
address sizes : 40 bits physical, 48 bits virtual
MemTotal: 16331852 kB
CentOS release 6.10 (Final)
Linux VM_0_15_centos 2.6.32-754.27.1.el6.x86_64 #1 SMP Tue Jan 28 14:11:45 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
- Nginx
nginx/1.16.1- PHP
PHP 7.3.15 (cli) (built: Mar 2 2020 17:53:06) ( NTS )
PHP 7.3.15 (fpm-fcgi) (built: Mar 2 2020 17:53:08)- Laravel
Laravel Framework 6.18.1- Mysql
Mysql 5.7.1.7
Abs -n 5000 -c 500 https://api.mydomain.cn/api/live/live_history
Php-fpm 进程监控
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
27304 www 20 0 783m 567m 8548 R 99.4 3.6 5139:39 php-fpm
Postman 同时请求https://api.mydomain.cn/api/live/live_history,返回结果
Time:36.76s size:4.98KB
Abs 返回结果
d:\Vue.js>abs -n 5000 -c 500 https://api.mydomain.cn/api/live/live_history
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking api.mydomain.cn (be patient)
Completed 500 requests
Completed 1000 requests
Completed 1500 requests
Completed 2000 requests
Completed 2500 requests
Completed 3000 requests
Completed 3500 requests
Completed 4000 requests
Completed 4500 requests
Completed 5000 requests
Finished 5000 requests
Server Software: nginx/1.16.1
Server Hostname: api.mydomain.cn
Server Port: 443
SSL/TLS Protocol: TLSv1/SSLv3,AES256-SHA,2048,256
Document Path: /api/live/live_history
Document Length: 630 bytes
Concurrency Level: 500
Time taken for tests: 375.114 seconds
Complete requests: 5000
Failed requests: 0
Write errors: 0
Non-2xx responses: 5000
Total transferred: 5790000 bytes
HTML transferred: 3150000 bytes
Requests per second: 13.33 [#/sec] (mean)
Time per request: 37511.384 [ms] (mean)
Time per request: 75.023 [ms] (mean, across all concurrent requests)
Transfer rate: 15.07 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 21 330 973.7 34 5480
Processing: 540 35141 6388.9 36859 37954
Waiting: 539 35140 6388.8 36859 37954
Total: 5792 35471 5427.8 36899 38046
Percentage of the requests served within a certain time (ms)
50% 36899
66% 37218
75% 37329
80% 37416
90% 37507
95% 37585
98% 37712
99% 37881
100% 38046 (longest request)
Abs -n 5000 -c 500 https://api.mydomain.cn/api/live/live_history
Php-fpm进程监控
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
18281 www 20 0 252m 24m 16m R 93.4 0.2 0:47.95 php-fpm
Postman 同时请求结果
Time:4.41s size:4.98KB
Abs返回结果
d:\Vue.js>abs -n 5000 -c 500 https://api.mydomain.cn/api/live/live_history
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking api.mydomain.cn (be patient)
Completed 500 requests
Completed 1000 requests
Completed 1500 requests
Completed 2000 requests
Completed 2500 requests
Completed 3000 requests
Completed 3500 requests
Completed 4000 requests
Completed 4500 requests
Completed 5000 requests
Finished 5000 requests
Server Software: nginx/1.16.1
Server Hostname: api.mydomain.cn
Server Port: 443
SSL/TLS Protocol: TLSv1/SSLv3,AES256-SHA,2048,256
Document Path: /api/live/live_history
Document Length: 630 bytes
Concurrency Level: 500
Time taken for tests: 64.823 seconds
Complete requests: 5000
Failed requests: 0
Write errors: 0
Non-2xx responses: 5000
Total transferred: 5790000 bytes
HTML transferred: 3150000 bytes
Requests per second: 77.13 [#/sec] (mean)
Time per request: 6482.258 [ms] (mean)
Time per request: 12.965 [ms] (mean, across all concurrent requests)
Transfer rate: 87.23 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 31 754 1078.9 482 6549
Processing: 491 5139 872.1 5295 6037
Waiting: 491 5067 870.2 5244 6014
Total: 4787 5893 386.0 5852 7456
Percentage of the requests served within a certain time (ms)
50% 5852
66% 5961
75% 6011
80% 6043
90% 6231
95% 6699
98% 7077
99% 7235
100% 7456 (longest request)
Abs -n 5000 -c 500 https://api.mydomain.cn/api/live/live_history
Php-fpm进程监控
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
19312 www 20 0 254m 27m 17m S 79.1 0.2 1:50.32 php-fpm
Postman 同时请求返回结果
Time:1.033s size:4.98KB
Abs返回结果
d:\Vue.js>abs -n 5000 -c 500 https://api.mydomain.cn/api/live/live_history
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking api.mydomain.cn (be patient)
Completed 500 requests
Completed 1000 requests
Completed 1500 requests
Completed 2000 requests
Completed 2500 requests
Completed 3000 requests
Completed 3500 requests
Completed 4000 requests
Completed 4500 requests
Completed 5000 requests
Finished 5000 requests
Server Software: nginx/1.16.1
Server Hostname: api.mydomain.cn
Server Port: 443
SSL/TLS Protocol: TLSv1/SSLv3,AES256-SHA,2048,256
Document Path: /api/live/live_history
Document Length: 630 bytes
Concurrency Level: 500
Time taken for tests: 57.450 seconds
Complete requests: 5000
Failed requests: 0
Write errors: 0
Non-2xx responses: 5000
Total transferred: 5790000 bytes
HTML transferred: 3150000 bytes
Requests per second: 87.03 [#/sec] (mean)
Time per request: 5745.002 [ms] (mean)
Time per request: 11.490 [ms] (mean, across all concurrent requests)
Transfer rate: 98.42 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 31 2897 857.3 2992 6368
Processing: 404 2406 812.3 2349 5342
Waiting: 336 1965 722.0 1880 5256
Total: 2203 5303 762.1 5358 7047
Percentage of the requests served within a certain time (ms)
50% 5358
66% 5407
75% 5457
80% 5514
90% 5910
95% 6680
98% 6862
99% 6881
100% 7047 (longest request)
本次压测使用abs工具,模拟500用户并发请求5000次,站点的吞吐率(Requests per second)未优化前13.33/秒,优化后提升到87.03/秒,站点并发处理性能明显提升了近6.5倍。
Requests per second: 13.33 [#/sec] (mean)
Time per request: 37511.384 [ms] (mean)
Time per request: 75.023 [ms] (mean, across all concurrent requests)
Requests per second: 87.03 [#/sec] (mean)
Time per request: 5745.002 [ms] (mean)
Time per request: 11.490 [ms] (mean, across all concurrent requests)
加强自身代码的流程结构优化和业务逻辑合理化,比任何软硬件加速解决方案更重要,是开发与运维的根本。
高并优化具体解决方案另起章节。
本章完