PHP swoole and nodeJs Performance Analysis

Source: Internet
Author: User

Js has a nodejs. Our Technical boss sent a technical email some time ago saying that php supports multithreading, Asynchronization, and non-blocking, and said that nodejs should be destroyed, on the official website, swoole's performance is already at least comparable to that of nodejs. We need to use data to talk about it. We can test these two items when we are free on weekends! The following is the test report.

First, I use port 127.0.0.1: 8000 to test swoole and 127.0.0.1: 1337 to test nodejs.

There is a picture with the truth: (it will be passed in later, and it will not be saved on mac! Khan! Who will teach me! Programming has become silly)

Test environment:

Processor: 2.7 GHz i7

Memory: 16 GB 1600 hz DDR3

System MAC OS X

Put the test results 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 requestsCompleted 1000 requestsCompleted 1500 requestsCompleted 2000 requestsCompleted 2500 requestsCompleted 3000 requestsCompleted 3500 requestsCompleted 4000 requestsCompleted 4500 requestsCompleted 5000 requestsFinished 5000 requestsServer Software:        Server Hostname:        127.0.0.1Server Port:            8000Document Path:          /Document Length:        0 bytesConcurrency Level:      100Time taken for tests:   1.411 secondsComplete requests:      5000Failed requests:        0Write errors:           0Total transferred:      55330 bytesHTML transferred:       0 bytesRequests 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] receivedConnection Times (ms)              min  mean[+/-sd] median   maxConnect:        0    3   1.2      3       7Processing:    17   25  16.7     23     143Waiting:        1    9  12.9      7     136Total:         20   28  16.6     26     143Percentage 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)

2. nodejs test results:

~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 requestsCompleted 1000 requestsCompleted 1500 requestsCompleted 2000 requestsCompleted 2500 requestsCompleted 3000 requestsCompleted 3500 requestsCompleted 4000 requestsCompleted 4500 requestsCompleted 5000 requestsFinished 5000 requestsServer Software:        Server Hostname:        127.0.0.1Server Port:            1337Document Path:          /Document Length:        12 bytesConcurrency Level:      100Time taken for tests:   1.215 secondsComplete requests:      5000Failed requests:        0Write errors:           0Total transferred:      565000 bytesHTML transferred:       60000 bytesRequests 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] receivedConnection Times (ms)              min  mean[+/-sd] median   maxConnect:        0    0   0.6      0       5Processing:     2   24  21.0     21     175Waiting:        2   24  20.8     21     174Total:          6   24  20.9     21     175Percentage 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)

In the above AB test, a total of 100 concurrent requests per second were sent to the interface for 5000 times.

PHP and nodejs scored well. The key is that I used the Swoole environment-debug causes many commands to be output and will not be changed back for the time being (I will re-test it in the company testing environment later)

Time taken for tests: 1.411 seconds total Time consumption

Requests per secondd: 3543.00 [#/sec] (mean)

NodeJS

Time taken for tests: 1.215 seconds total Time consumption

Requests per secondd: 4116.49 [#/sec] (mean)

From the test results, although the swoole test data is slightly inferior, this does not affect my views on swoole (and the configuration may not be very good ), I think PHP written in C language is much better than our current environment.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.