Home > Article > Backend Development > PHP swoole and nodeJs performance analysis_PHP tutorial
js has a nodejs. Our technical boss sent a technical email some time ago saying that php supports multi-threading, asynchronous, and non-blocking. He also said that nodejs would be destroyed. The official website said that the performance of swoole is at least as good as Nodejs is comparable. This requires data to speak for itself. I tested these two things when I had time on the weekend! Below is the test report.
First I used port 127.0.0.1:8000 to test swoole and 127.0.0.1:1337 to test nodejs
There are pictures and the truth: (I will upload it later, I don’t know how to save screenshots on Mac! Sigh! Can any of you viewers teach me how to do it! Programming has become stupid)
Test environment:
Processor: 2.7GHz i7
Memory: 16GB 1600hz DDR3
System MAC OS X
The test results will be posted first:
1.PHPswoole test results:
~mysql|? ab -n 5000 -c 100 http://127.0.0.1:8000/ 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 127.0.0.1 (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: Server Hostname: 127.0.0.1 Server Port: 8000 Document Path: / Document Length: 0 bytes Concurrency Level: 100 Time taken for tests: 1.411 seconds Complete requests: 5000 Failed requests: 0 Write errors: 0 Total transferred: 55330 bytes HTML transferred: 0 bytes Requests per second: 3543.00 [#/sec] (mean) Time per request: 28.225 [ms] (mean) Time per request: 0.282 [ms] (mean, across all concurrent requests) Transfer rate: 38.29 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 0 3 1.2 3 7 Processing: 17 25 16.7 23 143 Waiting: 1 9 12.9 7 136 Total: 20 28 16.6 26 143 Percentage of the requests served within a certain time (ms) 50% 26 66% 27 75% 27 80% 27 90% 28 95% 29 98% 141 99% 142 100% 143 (longest request)
~mysql|? ab -n 5000 -c 100 http://127.0.0.1:1337/ 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 127.0.0.1 (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: Server Hostname: 127.0.0.1 Server Port: 1337 Document Path: / Document Length: 12 bytes Concurrency Level: 100 Time taken for tests: 1.215 seconds Complete requests: 5000 Failed requests: 0 Write errors: 0 Total transferred: 565000 bytes HTML transferred: 60000 bytes Requests per second: 4116.49 [#/sec] (mean) Time per request: 24.293 [ms] (mean) Time per request: 0.243 [ms] (mean, across all concurrent requests) Transfer rate: 454.26 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 0 0 0.6 0 5 Processing: 2 24 21.0 21 175 Waiting: 2 24 20.8 21 174 Total: 6 24 20.9 21 175 Percentage of the requests served within a certain time (ms) 50% 21 66% 22 75% 23 80% 24 90% 26 95% 32 98% 159 99% 170 100% 175 (longest request)
The results of PHP and nodejs are pretty good. The key is that I used --debug in the Swoole environment, which resulted in a lot of commands being output. I will not change it back for the time being. (I will retest it in the company's test environment later)
Time taken for tests: 1.411 seconds Total time spent
Requests per second: 3543.00 [#/sec] (mean)
nodeJS
Time taken for tests: 1.215 seconds Total time spent
Requests per second: 4116.49 [#/sec] (mean)
Judging from the test results, although the test data of swoole is slightly inferior, it does not affect my opinion of swoole (besides, the configuration may not be very good). I feel that for a PHP written in C language, this It’s already much better than our current environment.