PHP 7.1+ Swoole v1.9.5与Node.js基准测试PHP7 + Swoole击败Node.js

我想介绍一下这个Swoole PHP扩展:
事件驱动的异步&并发&协同网络引擎,为PHP提供高性能.http://www.swoole.com/

这是一个改变游戏规则的扩展,它将改变PHP的工作方式。
根据这里的基准标记,它比Node.js快12倍。
试试swoole扩展。

Ubuntu 16.04 LTS
Intel® Core™ i5-4590 CPU @ 3.30GHz × 4
16G Memory

set([
    'worker_num' => 4,
]);

$data = [
  'code' => 'ok',
  'error' => false,
  'payload' => 'Hello World'
];

$http->on('request', function ($request, swoole_http_response $response)  use($data)  {
    $response->header('Content-Type', 'application/json');   
    $response->end(json_encode($data));
});

$http->start();

Node.js v4.2.6

wrk -t4 -c400 -d10s http://127.0.0.1:1337/
Running 10s test @ http://127.0.0.1:1337/
  4 threads and 400 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency    16.08ms    2.70ms 237.82ms   90.94%
    Req/Sec     6.05k   510.34     7.10k    91.00%
  240668 requests in 10.02s, 46.36MB read
Requests/sec:  24026.00
Transfer/sec:      4.63MB

PHP7.1+Swoole-v1.9.5

wrk -t4 -c400 -d10s http://127.0.0.1:1337/
Running 10s test @ http://127.0.0.1:1337/
  4 threads and 400 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     1.46ms    1.42ms  27.96ms   85.66%
    Req/Sec    75.29k    36.43k  183.55k    72.75%
  3007806 requests in 10.06s, 605.25MB read
Requests/sec: 299103.32
Transfer/sec:     60.19MB

当然如果你用其他的node.js版本的测试,可以在评论区分析出来。

你可能感兴趣的:(PHP 7.1+ Swoole v1.9.5与Node.js基准测试PHP7 + Swoole击败Node.js)