Peak showdown: node. JS and PHP Performance testing

Source: Internet
Author: User
Tags connection pooling

about the contestants:

node. js, the server-side JavaScript language, with excellent event-driven and I/O asynchrony, is more like a Mitsubishi evlution Xwith excellent performance;

PHP, a familiar service-side language, has a fairly high market share in the Internet, and is more like a BMW 330iwith outstanding performance and high brand awareness.


Driver and Tester Introduction:

Network Environment: Intranet

Driver (Stress test server):

Server System: Linux 2.6.18

Server configuration: Intel (R) Xeon (TM) CPU 3.40GHz 4 CPUS

Memory: 6GB


Tester (Contract server):

Contract Tool: Apache 2.2.19 's own AB test tool

Server System: Linux 2.6.18

Server configuration: Pentium (R) dual-core CPU E5800 @ 3.20GHz 2CPUS

Memory: 1GB


Vehicle Description:

Mitsubishi evlution X (node. js): EVO (node) hereafter

Version: V0.4.9;

Officially provides performance: 6985req/sec (HTTP request);

Modification situation:

1. Turbo-Booster Kit: multi-node (Multi-core server to open the node process to improve performance);

2, sports shock absorber and site Kit: Generic-pool (link pool, to improve the performance of MySQL, Redis and other I/O operations);


BMW 330i (PHP): The following abbreviation (PHP)

Version:5.2.17;

Official performance: 8220 Req/sec (HTTP request);

Modification situation:

BMW Modified Acschnitzer provides: nginx+fastcgi;


Note: Perhaps my PHP configuration is not the optimization, should also be faster, some of the following test configuration is based on the article on the Internet configuration, if the master to match, the estimated PHP performance can also improve about 50%, so this test data for reference only.

configuration is based on Zhang Yi's blog and then modified according to the actual situation, the original address:http://blog.s135.com/nginx_php_v6/


Order:

for the original EVO (node) and a modified How much performance will be worse between the EVO (node) ? We asked them to try a little bit on the field.

Test content:

A get operation is performed on the Redis key value, and this value is returned. The pressure was 3000, 5000, 7000, and 30 seconds for pressure measurement.


Com 3000/30 3000/30 3000/30 5000/30 5000/30 5000/30 7000/30 7000/30 7000/30
Type Node0 Node1 Node2 Node0 Node1 Node2 Node0 Node1 Node2
RPs 4025 5479 5262 3913 5283 5353 3823 5258 5269
Tpq 0.24 0.18 0.19 0.26 0.19 0.18 0.26 0.21 0.19
80%req 63 131 671 448 417 1210 1961 856 1650
Fail 0 0 0 0 0 0 227 0 0

Description: (hereinafter)

Node0 said the original, Node1 said only multi-node modification, Node2 said multi-node and generic-pool modification.

3000/30: Delegate command./ab-c 3000-t http://10.1.10.150:8888/

RPS: Represents the number of requests processed per second, and the main indicators of concurrency

TPQ: The time per request processing, in milliseconds.

Fail: Represents the average number of failed requests processed

80%req: The number of milliseconds that the request representing 80% is returned.


Next we look at the operation of MySQL, the difference between the 3, the testtable for MySQL select * operation, TestTable has 2 fields, 1 data. Returns the name value of test.


Com 3000/30 3000/30 3000/30 5000/30 5000/30 5000/30 7000/30 7000/30 7000/30
Type Node0 Node1 Node2 Node0 Node1 Node2 Node0 Node1 Node2
RPs 1247 2465 2999 1211 2451 3013 1243 2440 3054
Tpq 0.82 0.40 0.33 0.82 0.41 0.33 0.80 0.42 0.33
80%req 2424 2080 627 4329 3103 1365 5433 3610 3188
Fail 0 0 0 0 0 0 0 0 0


The application of multi-node obviously greatly improves node performance, and connection pooling can only be better in certain situations.

The longer the connection time, the more complex the operation DB, such as multiple key or sort operations on the Redis, the performance of the connection pool can be more evident.


Specifically how to refit Evo (node), see my blog: http://snoopyxdy.blog.163.com/blog/static/601174402011841174351/


Chapter1: Fighting between men, 0-400m linear acceleration

The 0-400-meter straight race, also known as the "straight speed race", is a race for racing performance, and there is no way to escape, but to move forward.

in an empty airfield, The EVO (node) and the (PHP) are preparing for an unarmed battle.

Test content:

Test the "Hello World" Web server with an empty framework without any business load.


Com 3000/30 3000/30 5000/30 5000/30 7000/30 7000/30
Type Node Php Node Php Node Php
RPs 7677 3624 7232 3760 6743 3731
Tpq 0.13 0.39 0.14 0.41 0.15 0.42
80%req 138 843 477 1343 898 2445
Fail 0 0 0 0 0 0

The EVO (node) is in the Multi-node 4 Turbo (4CPU), leading the way until the end, but in the test 4 CPUs have been saturated, and if there are 8 cores, it is estimated to be faster.

and PHP because my rookie-level configuration modification, can not fully play his performance, on-line TX will be PHP bare ben to 5000+rps, we can refer to.



Chapter2: Urban street running, considering your driving skills

running on the road of the city, you will often see two cars have been whistling from your side, along with the roar of the engine, you can feel the speed of passion. as if we often shuttle in the bustling city, so first the production of the most commonly used in the comparison of MySQL test.

Test content:

For a SELECT * operation on the data table test, there is only one data in the test data table, 2 fields, then the name is returned and the value is test.


Com 3000/30 3000/30 5000/30 5000/30 7000/30 7000/30
Type Node Php Node Php Node Php
RPs 2999 1293 3013 1349 3054 1301
Tpq 0.33 0.82 0.33 0.80 0.33 0.80
80%req 627 1369 1365 1979 3188 3903
Fail 0 0 0 111 0 573


MySQL is both build and release connections are relatively long, so node and PHP performance compared to bare Ben have dropped sharply.

Because PHP requires a release connection for each request, it takes longer.

and the EVO (node) at this time the advantages of play out, Multi-node and Generic-pool two big weapon seamless cooperation, in the streets and corners far away from the " (PHP)."

Or the old saying, maybe the php conversion is not in place, you do a reference.


Chapter3: The city elevated, the tunnel, the ramp is our stage to show the speed

The emergence of the elevated is to alleviate the increasingly congested urban traffic, elevated not only the world of luxury cars, but also the performance of the car stage, let us experience smashing the seconds to kill all the thrill of it.

Memcache is the best tool to alleviate MySQL bottlenecks, Php+memcache+mysql has always been a classic combination, widely used in all major Internet sites.

Test content:

Take a value for the "test" key of Memcache and return the value "test".


Com 3000/30 3000/30 5000/30 5000/30 7000/30 7000/30
Type Node Php Node Php Node Php
RPs 5102 1957 4995 1841 4976 1872
Rpt 0.2 0.64 0.2 0.74 0.19 0.70
80%req 672 1713 1033 2150 1494 3551
Fail 0 7 0 79 0 335


Compared to MySQL, Memcache set up and release connection time is shorter, and directly manipulate the memory, so the test results of both have a lot of rise.

Here PHP is still limited by the loss of his establishment and release of the connection, the results are not ideal.


Chapter4: Battle of the Nurburgring

the real car has to conquer the king of the circuit, the North ring of the German Nurburgring, which is known as Green Hell's 20.6km track is to let the racing high-speed shuttle between the original mountain, the track with the mountains and ups and downs, like a roller coaster. EVO's best performance on this track was 7 minutes and 32 seconds 52, while Ac-schnitzer modified the BMW M3, the best result was 7 minutes and 36 seconds.

In the era of high-speed information, our desire for speed is more intense, redis as a high-speed NoSQL memory db, with its excellent performance by the public recognition, more and more Internet sites are now added to the ranks of NoSQL.

Test content:

Take a value for Redis's "test" key and return the value "test".


Com 3000/30 3000/30 5000/30 5000/30 7000/30 7000/30
Type Node Php Node Php Node Php
RPs 5262 2015 5353 1949 5269 1901
Tpq 0.19 0.61 0.18 0.61 0.19 0.61
80%req 671 1805 1210 2356 1650 3816
Fail 0 0 0 105 0 607


This test result and memcache difference is not small, because Redis and memcache compared to his advantage is no longer key-value, but hash and sort, as well as pub/sub, so in pure key-value, this test performance is not comparable.

Finally, at the Nurburgring North ring Circuit,EVO (node) first crossed the finish line and became the winner of this comparison.


End:

I think the results of this test should have been expected as early as you can, event-driven for less memory consumption, non-blocking and join pool joins allow node to take the I/O operation to the higher level.

Although PHP has fallen on all fronts, it does not mean that PHP is less likely to have a more suitable application scenario and a broad open source framework and technical support for node,php.

Node as a new type of server language from the recognized, to widely used in production environment to go a long way.


There is a picture of true image:


This is in 3000 concurrent bursts 30 seconds test, if 1000 concurrent bursts 30 seconds can go to 8000 +.

See:



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.