ReactPHP vs Node.js · GitHub

您所在的位置:网站首页 reactphp ReactPHP vs Node.js · GitHub

ReactPHP vs Node.js · GitHub

2023-04-09 02:49| 来源: 网络整理| 查看: 265

Node.js v6

Running 10s test @ http://127.0.0.1:1337/ 4 threads and 400 connections Thread Stats Avg Stdev Max +/- Stdev Latency 33.73ms 11.66ms 276.14ms 89.75% Req/Sec 2.78k 246.07 3.09k 92.50% 110714 requests in 10.01s, 21.33MB read Requests/sec: 11061.55 Transfer/sec: 2.13MB

PHP 5.6 + StreamSelectLoop

Running 10s test @ http://127.0.0.1:1337/ 4 threads and 400 connections Thread Stats Avg Stdev Max +/- Stdev Latency 21.47ms 100.17ms 1.75s 98.43% Req/Sec 797.22 161.79 1.25k 63.00% 31743 requests in 10.01s, 5.09MB read Socket errors: connect 0, read 31743, write 0, timeout 29 Requests/sec: 3169.99 Transfer/sec: 520.08KB

PHP 5.6 + LibEventLoop

Running 10s test @ http://127.0.0.1:1337/ 4 threads and 400 connections Thread Stats Avg Stdev Max +/- Stdev Latency 22.29ms 99.64ms 1.77s 98.33% Req/Sec 759.40 211.63 1.30k 69.00% 30235 requests in 10.01s, 4.84MB read Socket errors: connect 0, read 30250, write 0, timeout 22 Requests/sec: 3020.05 Transfer/sec: 495.48KB

PHP 5.6 + ExtEventLoop

Running 10s test @ http://127.0.0.1:1337/ 4 threads and 400 connections Thread Stats Avg Stdev Max +/- Stdev Latency 21.13ms 92.95ms 1.89s 98.73% Req/Sec 721.25 192.93 1.16k 62.75% 28728 requests in 10.01s, 4.60MB read Socket errors: connect 0, read 28725, write 0, timeout 26 Requests/sec: 2869.25 Transfer/sec: 470.74KB

PHP 5.6 + LibEvLoop

Running 10s test @ http://127.0.0.1:1337/ 4 threads and 400 connections Thread Stats Avg Stdev Max +/- Stdev Latency 27.46ms 121.37ms 1.62s 97.54% Req/Sec 766.31 243.96 1.25k 67.50% 30526 requests in 10.01s, 4.89MB read Socket errors: connect 0, read 30525, write 0, timeout 23 Requests/sec: 3048.09 Transfer/sec: 500.08KB

PHP 7.0 + StreamSelectLoop

Running 10s test @ http://127.0.0.1:1337/ 4 threads and 400 connections Thread Stats Avg Stdev Max +/- Stdev Latency 33.61ms 152.67ms 1.93s 96.21% Req/Sec 1.18k 342.69 2.07k 65.25% 46961 requests in 10.01s, 7.52MB read Socket errors: connect 0, read 46960, write 0, timeout 37 Requests/sec: 4691.54 Transfer/sec: 769.71KB

PHP 7.0 + ExtEventLoop

Running 10s test @ http://127.0.0.1:1337/ 4 threads and 400 connections Thread Stats Avg Stdev Max +/- Stdev Latency 30.01ms 132.79ms 1.92s 96.86% Req/Sec 1.04k 411.40 2.26k 65.99% 41411 requests in 10.01s, 6.63MB read Socket errors: connect 0, read 41409, write 0, timeout 48 Requests/sec: 4135.73 Transfer/sec: 678.52KB

ReactPHP 0.4.1 + PHP 7.1 + StreamSelectLoop

Running 10s test @ http://127.0.0.1:1337/ 4 threads and 400 connections Thread Stats Avg Stdev Max +/- Stdev Latency 24.44ms 121.70ms 1.88s 97.26% Req/Sec 1.18k 316.86 1.96k 68.00% 47053 requests in 10.01s, 7.54MB read Socket errors: connect 0, read 47053, write 0, timeout 36 Requests/sec: 4698.87 Transfer/sec: 770.91KB

ReactPHP Dev + PHP 7.1 + StreamSelectLoop

Running 10s test @ http://127.0.0.1:1337/ 4 threads and 400 connections Thread Stats Avg Stdev Max +/- Stdev Latency 33.93ms 149.99ms 1.88s 95.62% Req/Sec 1.39k 406.67 2.76k 68.25% 55544 requests in 10.06s, 8.90MB read Socket errors: connect 0, read 55543, write 0, timeout 46 Requests/sec: 5520.35 Transfer/sec: 0.88MB

Notes:

PHP 7 is considerably faster There is not much difference between PHP 7 and PHP 7.1 in this case The result on different platforms is not consistent and highly dependent, for example on a virtual machine using ubuntu i couldn't get pass 70 req/sec!! comparing to two nodejs 12,000 req/sec In some cases StreamSelectLoop is actually quite sufficient and no extension is really needed. but i'm also suspicous because, because extensions should be much faster, so they might be some sort of a limit on Linux. Note that it seems nodejs uses libuv which is a crossplatform asynchronous I/O library, good news is that PHP 7 also supports it, reactphp does not yet support it but hopefully in near future it becomes PHP standard library and included by default in core If there is a PHP project that requires socket server and an even loop in general, there result is satisfiing enough that eliminate the need to port the whole thing to nodejs

Note that we are using ratchet-php as light WAMP socket server for two years now, it used to be buggy and resource hug but since the last year it became pretty much stable. I ran these benchmark to see if we can put under more traffic.



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3