PHP7.3+Swoole4.4 / Go1.13 / MixPHP2.2 / Beego1.12 性能对比

好几年没有做过性能对比了,因为越来越觉得性能并没有那么的重要(相对于生态),今天有时间简单测试一下,因为 Mix v2.1 开始就全部切换为单进程协程模式,因此本次主要测试的是 Co\Http\Server ,测试结果在最后面。

环境

  • CPU: Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz
  • CPU(s): 12
  • Mem: 15G
  • Linux version 3.10.0-957.10.1.el7.x86_64

PHP 7.3.12 + Swoole 4.4.14

代码中使用的单进程 Co\Http\Server ,因此需要利用端口复用 (需要 Linux >= 3.10),开启 12 个进程

  • 代码
<?php 

\Swoole\Process::daemon();

$scheduler = new \Swoole\Coroutine\Scheduler;
$scheduler->set([
    'hook_flags' => SWOOLE_HOOK_ALL,
]);
$scheduler->add(function () {

    $server = new \Swoole\Coroutine\Http\Server('0.0.0.0', 8888, false, true);
    $server->handle('/', function($request, $response){
        $response->end('hello, world!');
    });
    $server->start();

});
$scheduler->start();
  • 开启的进程
[nobody@tmp]$ ps -ef | grep test.php
nobody    1917     1  0 20:22 ?        00:00:02 /usr/local/php-7.3.12/bin/php test.php
nobody    1923     1  0 20:22 ?        00:00:02 /usr/local/php-7.3.12/bin/php test.php
nobody    1929     1  0 20:22 ?        00:00:02 /usr/local/php-7.3.12/bin/php test.php
nobody    1934     1  0 20:22 ?        00:00:02 /usr/local/php-7.3.12/bin/php test.php
nobody    2154     1  0 20:22 ?        00:00:02 /usr/local/php-7.3.12/bin/php test.php
nobody    2166     1  0 20:22 ?        00:00:02 /usr/local/php-7.3.12/bin/php test.php
nobody    2173     1  0 20:22 ?        00:00:02 /usr/local/php-7.3.12/bin/php test.php
nobody    2181     1  0 20:22 ?        00:00:02 /usr/local/php-7.3.12/bin/php test.php
nobody    2187     1  0 20:22 ?        00:00:02 /usr/local/php-7.3.12/bin/php test.php
nobody    2194     1  0 20:22 ?        00:00:02 /usr/local/php-7.3.12/bin/php test.php
nobody    2200     1  0 20:22 ?        00:00:02 /usr/local/php-7.3.12/bin/php test.php
nobody    2205     1  0 20:22 ?        00:00:02 /usr/local/php-7.3.12/bin/php test.php
  • 测试:多跑几次,基本稳定在 127441.95 左右。
[nobody@~]$ ab -n 100000 -c 1000 -k http://127.0.0.1:8888/
This is ApacheBench, Version 2.3 <$Revision: 1430300 $>
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 10000 requests
Completed 20000 requests
Completed 30000 requests
Completed 40000 requests
Completed 50000 requests
Completed 60000 requests
Completed 70000 requests
Completed 80000 requests
Completed 90000 requests
Completed 100000 requests
Finished 100000 requests


Server Software:        swoole-http-server
Server Hostname:        127.0.0.1
Server Port:            8888

Document Path:          /
Document Length:        13 bytes

Concurrency Level:      1000
Time taken for tests:   0.785 seconds
Complete requests:      100000
Failed requests:        0
Write errors:           0
Keep-Alive requests:    100000
Total transferred:      16600000 bytes
HTML transferred:       1300000 bytes
Requests per second:    127441.95 [#/sec] (mean)
Time per request:       7.847 [ms] (mean)
Time per request:       0.008 [ms] (mean, across all concurrent requests)
Transfer rate:          20659.53 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   2.4      0      47
Processing:     2    7   0.5      7      47
Waiting:        0    7   0.4      7      14
Total:          2    8   2.6      7      58

Percentage of the requests served within a certain time (ms)
  50%      7
  66%      7
  75%      7
  80%      7
  90%      8
  95%      8
  98%      8
  99%     18
 100%     58 (longest request)

Go 1.13.4

Golang 默认使用全部 CPU 线程,因此只需开启一个进程即可。

  • 代码
package main

import (
    "fmt"
    "net/http"
)

func main() {

    http.HandleFunc("/", func(writer http.ResponseWriter, request *http.Request) {
        writer.Write([]byte("hello, world!"))
    })
    err := http.ListenAndServe(":9999", nil)
    if err != nil{
        fmt.Println(err)
    }

}
  • 开启的进程
[nobody@~]$ ps -ef | grep gotest
nobody    4409  1859  0 20:25 pts/31   00:00:06 ./gotest_linux
  • 测试:多跑几次,基本稳定在 121575.23 左右,比 Swoole 稍微差点,但非常接近,PHP 是动态语言借助 Swoole 做到这个性能确实是非常夸张了。
[nobody@~]$ ab -n 100000 -c 1000 -k http://127.0.0.1:9999/
This is ApacheBench, Version 2.3 <$Revision: 1430300 $>
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 10000 requests
Completed 20000 requests
Completed 30000 requests
Completed 40000 requests
Completed 50000 requests
Completed 60000 requests
Completed 70000 requests
Completed 80000 requests
Completed 90000 requests
Completed 100000 requests
Finished 100000 requests


Server Software:
Server Hostname:        127.0.0.1
Server Port:            9999

Document Path:          /
Document Length:        13 bytes

Concurrency Level:      1000
Time taken for tests:   0.823 seconds
Complete requests:      100000
Failed requests:        0
Write errors:           0
Keep-Alive requests:    100000
Total transferred:      15400000 bytes
HTML transferred:       1300000 bytes
Requests per second:    121575.23 [#/sec] (mean)
Time per request:       8.225 [ms] (mean)
Time per request:       0.008 [ms] (mean, across all concurrent requests)
Transfer rate:          18283.77 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   2.4      0      46
Processing:     2    8   1.1      7      46
Waiting:        0    8   1.1      7      30
Total:          2    8   2.7      7      56

Percentage of the requests served within a certain time (ms)
  50%      7
  66%      8
  75%      9
  80%      9
  90%      9
  95%      9
  98%     10
  99%     18
 100%     56 (longest request)

MixPHP V2.2

接下来我们看一下跑在 PHP7.3 + Swoole4.4 下的 Mix V2.2 能跑多少。

  • 开启的进程
[nobody@tmp]$ ps -ef | grep mix.php
nobody   24783     1  0 20:51 ?        00:00:00 /usr/local/php-7.3.12/bin/php mix/bin/mix.php web -r -d
nobody   24801     1  0 20:51 ?        00:00:00 /usr/local/php-7.3.12/bin/php mix/bin/mix.php web -r -d
nobody   24821     1  0 20:51 ?        00:00:00 /usr/local/php-7.3.12/bin/php mix/bin/mix.php web -r -d
nobody   24839     1  0 20:51 ?        00:00:00 /usr/local/php-7.3.12/bin/php mix/bin/mix.php web -r -d
nobody   24856     1  0 20:51 ?        00:00:00 /usr/local/php-7.3.12/bin/php mix/bin/mix.php web -r -d
nobody   24873     1  0 20:51 ?        00:00:00 /usr/local/php-7.3.12/bin/php mix/bin/mix.php web -r -d
nobody   24891     1  0 20:51 ?        00:00:00 /usr/local/php-7.3.12/bin/php mix/bin/mix.php web -r -d
nobody   24908     1  0 20:51 ?        00:00:00 /usr/local/php-7.3.12/bin/php mix/bin/mix.php web -r -d
nobody   24927     1  0 20:51 ?        00:00:00 /usr/local/php-7.3.12/bin/php mix/bin/mix.php web -r -d
nobody   24946     1  0 20:51 ?        00:00:00 /usr/local/php-7.3.12/bin/php mix/bin/mix.php web -r -d
nobody   24963     1  0 20:51 ?        00:00:00 /usr/local/php-7.3.12/bin/php mix/bin/mix.php web -r -d
nobody   24981     1  0 20:51 ?        00:00:00 /usr/local/php-7.3.12/bin/php mix/bin/mix.php web -r -d
  • 测试:多跑几次,基本稳定在 110050.47 左右,比原生 Swoole 降低了 13.6%,整个框架的代码只降低了这个比例,还是蛮可以的。
[nobody@~]$ ab -n 100000 -c 1000 -k http://127.0.0.1:9501/
This is ApacheBench, Version 2.3 <$Revision: 1430300 $>
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 10000 requests
Completed 20000 requests
Completed 30000 requests
Completed 40000 requests
Completed 50000 requests
Completed 60000 requests
Completed 70000 requests
Completed 80000 requests
Completed 90000 requests
Completed 100000 requests
Finished 100000 requests


Server Software:        swoole-http-server
Server Hostname:        127.0.0.1
Server Port:            9501

Document Path:          /
Document Length:        13 bytes

Concurrency Level:      1000
Time taken for tests:   0.909 seconds
Complete requests:      100000
Failed requests:        0
Write errors:           0
Keep-Alive requests:    100000
Total transferred:      18100000 bytes
HTML transferred:       1300000 bytes
Requests per second:    110050.47 [#/sec] (mean)
Time per request:       9.087 [ms] (mean)
Time per request:       0.009 [ms] (mean, across all concurrent requests)
Transfer rate:          19452.28 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   2.5      0      45
Processing:     2    9   1.6      9      46
Waiting:        0    9   1.6      9      25
Total:          2    9   3.2      9      58

Percentage of the requests served within a certain time (ms)
  50%      9
  66%      9
  75%      9
  80%      9
  90%      9
  95%     10
  98%     17
  99%     23
 100%     58 (longest request)

我尝试减少进程测试:

  • 当减少到 5 个进程时达到最高性能
[nobody@tmp]$ ps -ef | grep mix.php
nobody   24946     1  0 20:51 ?        00:00:15 /usr/local/php-7.3.12/bin/php mix/bin/mix.php web -r -d
nobody   24963     1  0 20:51 ?        00:00:15 /usr/local/php-7.3.12/bin/php mix/bin/mix.php web -r -d
nobody   24981     1  0 20:51 ?        00:00:15 /usr/local/php-7.3.12/bin/php mix/bin/mix.php web -r -d
nobody   27471     1 22 21:35 ?        00:00:05 /usr/local/php-7.3.12/bin/php mix/bin/mix.php web -r -d
nobody   27522     1 18 21:35 ?        00:00:03 /usr/local/php-7.3.12/bin/php mix/bin/mix.php web -r -d
  • 测试:多跑几次,基本稳定在 114070.87 左右,比 12 个进程的时候还高一点,证明再多开进程已经无法提升性能了,12 线程的 CPU 为何会这样呢?
[nobody@~]$ ab -n 100000 -c 1000 -k http://127.0.0.1:9501/
This is ApacheBench, Version 2.3 <$Revision: 1430300 $>
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 10000 requests
Completed 20000 requests
Completed 30000 requests
Completed 40000 requests
Completed 50000 requests
Completed 60000 requests
Completed 70000 requests
Completed 80000 requests
Completed 90000 requests
Completed 100000 requests
Finished 100000 requests


Server Software:        swoole-http-server
Server Hostname:        127.0.0.1
Server Port:            9501

Document Path:          /
Document Length:        13 bytes

Concurrency Level:      1000
Time taken for tests:   0.877 seconds
Complete requests:      100000
Failed requests:        0
Write errors:           0
Keep-Alive requests:    100000
Total transferred:      18100000 bytes
HTML transferred:       1300000 bytes
Requests per second:    114070.87 [#/sec] (mean)
Time per request:       8.766 [ms] (mean)
Time per request:       0.009 [ms] (mean, across all concurrent requests)
Transfer rate:          20162.92 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   2.0      0      33
Processing:     0    8   3.0      8      33
Waiting:        0    8   3.0      8      24
Total:          0    9   3.7      8      43

Percentage of the requests served within a certain time (ms)
  50%      8
  66%      9
  75%     10
  80%     11
  90%     12
  95%     13
  98%     18
  99%     21
 100%     43 (longest request)

Beego V1.12.1

  • 代码:
package main

import (
    "fmt"
    "net/http"
    "runtime"
)

func main() {

    http.HandleFunc("/", func(writer http.ResponseWriter, request *http.Request) {
        writer.Write([]byte("hello, world!"))
    })
    err := http.ListenAndServe(":9999", nil)
    if err != nil{
        fmt.Println(err)
    }

}
  • 测试:多跑几次,基本稳定在 107428.35 左右,与 Mix 非常接近。
[nobody@~]$ ab -n 100000 -c 1000 -k http://127.0.0.1:8989/index
This is ApacheBench, Version 2.3 <$Revision: 1430300 $>
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 10000 requests
Completed 20000 requests
Completed 30000 requests
Completed 40000 requests
Completed 50000 requests
Completed 60000 requests
Completed 70000 requests
Completed 80000 requests
Completed 90000 requests
Completed 100000 requests
Finished 100000 requests


Server Software:        beegoServer:1.12.1
Server Hostname:        127.0.0.1
Server Port:            8989

Document Path:          /index
Document Length:        13 bytes

Concurrency Level:      1000
Time taken for tests:   0.931 seconds
Complete requests:      100000
Failed requests:        0
Write errors:           0
Keep-Alive requests:    100000
Total transferred:      18200000 bytes
HTML transferred:       1300000 bytes
Requests per second:    107428.35 [#/sec] (mean)
Time per request:       9.309 [ms] (mean)
Time per request:       0.009 [ms] (mean, across all concurrent requests)
Transfer rate:          19093.71 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   2.4      0      45
Processing:     0    9   2.4      9      52
Waiting:        0    9   2.4      9      52
Total:          0    9   3.4      9      57

Percentage of the requests served within a certain time (ms)
  50%      9
  66%      9
  75%      9
  80%      9
  90%      9
  95%     15
  98%     19
  99%     24
 100%     57 (longest request)

PHP 7.3.12 + Swoole 4.4.14 二次测试

上面减少到 5 个进程依然可以达到 12 进程的性能,我猜测可能是 ab -c 1000 只能达到 12w 左右的并发,也就是说没有打满,需要降低使用的线程数来测试,我们采用 2 个线程重新测试一下。

  • 先把测试进程减少到 2 个
[nobody@tmp]$ ps -ef | grep test.php
nobody    2200     1  0 7月22 ?       00:00:16 /usr/local/php-7.3.12/bin/php test.php
nobody    9600     1  0 10:30 ?        00:00:00 /usr/local/php-7.3.12/bin/php test.php
  • 测试:多跑几次,基本稳定在 136426.58 左右
[nobody@~]$ ab -n 100000 -c 1000 -k http://127.0.0.1:8888/
This is ApacheBench, Version 2.3 <$Revision: 1430300 $>
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 10000 requests
Completed 20000 requests
Completed 30000 requests
Completed 40000 requests
Completed 50000 requests
Completed 60000 requests
Completed 70000 requests
Completed 80000 requests
Completed 90000 requests
Completed 100000 requests
Finished 100000 requests


Server Software:        swoole-http-server
Server Hostname:        127.0.0.1
Server Port:            8888

Document Path:          /
Document Length:        13 bytes

Concurrency Level:      1000
Time taken for tests:   0.733 seconds
Complete requests:      100000
Failed requests:        0
Write errors:           0
Keep-Alive requests:    100000
Total transferred:      16600000 bytes
HTML transferred:       1300000 bytes
Requests per second:    136426.58 [#/sec] (mean)
Time per request:       7.330 [ms] (mean)
Time per request:       0.007 [ms] (mean, across all concurrent requests)
Transfer rate:          22116.03 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   2.2      0      43
Processing:     2    7   1.7      6      43
Waiting:        0    7   1.7      6      19
Total:          2    7   2.9      6      53

Percentage of the requests served within a certain time (ms)
  50%      6
  66%      6
  75%      6
  80%      7
  90%      8
  95%     10
  98%     16
  99%     18
 100%     53 (longest request)

Go 1.13.4 二次测试

  • 代码:修改为 2 个线程
package main

import (
    "fmt"
    "net/http"
    "runtime"
)

func main() {

    runtime.GOMAXPROCS(2) // 限制使用线程数

    http.HandleFunc("/", func(writer http.ResponseWriter, request *http.Request) {
        writer.Write([]byte("hello, world!"))
    })
    err := http.ListenAndServe(":9999", nil)
    if err != nil{
        fmt.Println(err)
    }

}

测试:多跑几次,基本稳定在 106834.75 左右,比 Swoole 性能低了 21.7%,证明 Swoole 确实性能是高于 Go 的 net 库。

[nobody@~]$ ab -n 100000 -c 1000 -k http://127.0.0.1:9999/
This is ApacheBench, Version 2.3 <$Revision: 1430300 $>
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 10000 requests
Completed 20000 requests
Completed 30000 requests
Completed 40000 requests
Completed 50000 requests
Completed 60000 requests
Completed 70000 requests
Completed 80000 requests
Completed 90000 requests
Completed 100000 requests
Finished 100000 requests


Server Software:
Server Hostname:        127.0.0.1
Server Port:            9999

Document Path:          /
Document Length:        13 bytes

Concurrency Level:      1000
Time taken for tests:   0.936 seconds
Complete requests:      100000
Failed requests:        0
Write errors:           0
Keep-Alive requests:    100000
Total transferred:      15400000 bytes
HTML transferred:       1300000 bytes
Requests per second:    106834.75 [#/sec] (mean)
Time per request:       9.360 [ms] (mean)
Time per request:       0.009 [ms] (mean, across all concurrent requests)
Transfer rate:          16066.95 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   1.5      0      21
Processing:     0    9   1.9      9      21
Waiting:        0    9   1.9      9      17
Total:          0    9   2.3      9      30

Percentage of the requests served within a certain time (ms)
  50%      9
  66%      9
  75%     10
  80%     10
  90%     11
  95%     12
  98%     13
  99%     17
 100%     30 (longest request)

MixPHP V2.2 二次测试

  • 先把测试进程减少到 2 个
[nobody@tmp]$ ps -ef | grep mix.php
nobody    7482     1  2 10:27 ?        00:00:05 /usr/local/php-7.3.12/bin/php mix/bin/mix.php web -r -d
nobody   27522     1  0 7月22 ?       00:00:35 /usr/local/php-7.3.12/bin/php mix/bin/mix.php web -r -d
  • 测试:多跑几次,基本稳定在 53856.21 左右,果然,按这个数据分析,之前 12 进程测试的数据不合理,因为 ab -c 1000 没有将 CPU 性能打满。
[nobody@~]$ ab -n 100000 -c 1000 -k http://127.0.0.1:9501/
This is ApacheBench, Version 2.3 <$Revision: 1430300 $>
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 10000 requests
Completed 20000 requests
Completed 30000 requests
Completed 40000 requests
Completed 50000 requests
Completed 60000 requests
Completed 70000 requests
Completed 80000 requests
Completed 90000 requests
Completed 100000 requests
Finished 100000 requests


Server Software:        swoole-http-server
Server Hostname:        127.0.0.1
Server Port:            9501

Document Path:          /
Document Length:        13 bytes

Concurrency Level:      1000
Time taken for tests:   1.857 seconds
Complete requests:      100000
Failed requests:        0
Write errors:           0
Keep-Alive requests:    100000
Total transferred:      18100000 bytes
HTML transferred:       1300000 bytes
Requests per second:    53856.21 [#/sec] (mean)
Time per request:       18.568 [ms] (mean)
Time per request:       0.019 [ms] (mean, across all concurrent requests)
Transfer rate:          9519.51 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   2.3      0      45
Processing:     0   18   5.5     17      46
Waiting:        0   18   5.5     17      38
Total:          0   18   5.6     17      55

Percentage of the requests served within a certain time (ms)
  50%     17
  66%     18
  75%     19
  80%     20
  90%     25
  95%     29
  98%     32
  99%     33
 100%     55 (longest request)

Beego V1.12.1

  • 代码:同样我们限制使用 2 个线程
package main

import (
    "github.com/astaxie/beego"
    _ "hello/routers"
    "runtime"
)

type IndexController struct {
    beego.Controller
}

func (c *IndexController) Index() {
    c.Ctx.Output.Body([]byte("hello, world!"))
}

func main() {

    runtime.GOMAXPROCS(2) // 限制使用线程数

    beego.Router("/index", &IndexController{},"*:Index")

    beego.Run()

}
  • 测试:多跑几次,基本稳定在 54547.49 左右,与 Mix 非常接近。
[nobody@~]$ ab -n 100000 -c 1000 -k http://127.0.0.1:8989/index
This is ApacheBench, Version 2.3 <$Revision: 1430300 $>
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 10000 requests
Completed 20000 requests
Completed 30000 requests
Completed 40000 requests
Completed 50000 requests
Completed 60000 requests
Completed 70000 requests
Completed 80000 requests
Completed 90000 requests
Completed 100000 requests
Finished 100000 requests


Server Software:        beegoServer:1.12.1
Server Hostname:        127.0.0.1
Server Port:            8989

Document Path:          /index
Document Length:        13 bytes

Concurrency Level:      1000
Time taken for tests:   1.833 seconds
Complete requests:      100000
Failed requests:        0
Write errors:           0
Keep-Alive requests:    100000
Total transferred:      18200000 bytes
HTML transferred:       1300000 bytes
Requests per second:    54547.49 [#/sec] (mean)
Time per request:       18.333 [ms] (mean)
Time per request:       0.018 [ms] (mean, across all concurrent requests)
Transfer rate:          9694.96 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   1.9      0      31
Processing:     0   18   6.3     19      40
Waiting:        0   18   6.3     19      40
Total:          0   18   6.3     19      41

Percentage of the requests served within a certain time (ms)
  50%     19
  66%     21
  75%     22
  80%     22
  90%     24
  95%     25
  98%     28
  99%     31
 100%     41 (longest request)

总结一下

  • 第一次测试:由于 ab -c 1000 测试的性能没有把 CPU 打满,导致测试结果不公正,应该很多人会忽略这个问题,认为自己的框架性能很高,其实是没有打满。
语言/框架 进/线程数 数值
PHP 7.3.12 + Swoole 4.4.14 12 127441.95
Go 1.13.4 1 <12线程> 121575.23
PHP 7.3.12 + Swoole 4.4.14 + MixPHP 2.2 12 110050.47
Go 1.13.4 + Beego 1.12.1 12 107428.35
  • 第二次测试:采用 2 线程测试比较公正,能打满 CPU ,这样出来的结果才是真实结果,Swoole 比 Go 性能高 21.7% (毕竟是 C 写的),Mix 比 Swoole 原生降低了 60.5% 的性能,而 Mix 大概是 Go 原生一半的性能,与 Beego 性能齐平。
语言/框架 进/线程数 数值
PHP 7.3.12 + Swoole 4.4.14 2 136426.58
Go 1.13.4 1 <2线程> 106834.75
PHP 7.3.12 + Swoole 4.4.14 + MixPHP 2.2 2 53856.21
Go 1.13.4 + Beego 1.12.1 2 54547.49
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 216,163评论 6 498
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 92,301评论 3 392
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 162,089评论 0 352
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 58,093评论 1 292
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 67,110评论 6 388
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 51,079评论 1 295
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 40,005评论 3 417
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 38,840评论 0 273
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 45,278评论 1 310
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,497评论 2 332
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 39,667评论 1 348
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 35,394评论 5 343
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 40,980评论 3 325
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,628评论 0 21
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,796评论 1 268
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 47,649评论 2 368
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,548评论 2 352