服务器配置

  • 操作系统CentOS 7.2 64位
  • CPU1 核
  • 内存2 GB
  • 公网带宽1 Mbps

Swoole  2.1.2-alpha

<?php
$http = new swoole_http_server("127.0.0.1", 9501);

$http->on("start", function ($server) {
    echo "Swoole http server is started at http://127.0.0.1:9501\n";
});

$http->on("request", function ($request, $response) {
    $response->header("Content-Type", "text/plain");
    $response->end("Hello World\n");
});

$http->start();
ab -c100 -n100000 http://127.0.0.1:9501/
Server Software:        nginx
Server Hostname:        127.0.0.1
Server Port:            80

Document Path:          /helloworld.php
Document Length:        11 bytes

Concurrency Level:      100
Time taken for tests:   20.609 seconds
Complete requests:      100000
Failed requests:        0
Write errors:           0
Total transferred:      18900000 bytes
HTML transferred:       1100000 bytes
Requests per second:    4852.13 [#/sec] (mean)
Time per request:       20.609 [ms] (mean)
Time per request:       0.206 [ms] (mean, across all concurrent requests)
Transfer rate:          895.56 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.1      0       3
Processing:     3   20   6.3     20     153
Waiting:        1   20   6.3     20     153
Total:          3   21   6.3     20     154

PHP 7.2.3

<?php
echo 'hello world';
ab -c100 -n100000 http://127.0.0.1/helloworld.php
Server Software:        swoole-http-server
Server Hostname:        127.0.0.1
Server Port:            9501

Document Path:          /
Document Length:        12 bytes

Concurrency Level:      100
Time taken for tests:   5.758 seconds
Complete requests:      100000
Failed requests:        0
Write errors:           0
Total transferred:      16100000 bytes
HTML transferred:       1200000 bytes
Requests per second:    17368.14 [#/sec] (mean)
Time per request:       5.758 [ms] (mean)
Time per request:       0.058 [ms] (mean, across all concurrent requests)
Transfer rate:          2730.73 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    1   0.4      1       4
Processing:     3    4   0.9      4      54
Waiting:        2    3   0.6      3      52
Total:          4    6   0.9      5      54

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注