MixPHP 与 Phalcon 并发压力测试

说起 PHP 高性能框架,一定会有人说 Yaf/Phalcon,这两个C扩展类型的框架基本是高性能框架的代表了,而 MixPHP 是基于 Swoole 扩展的高性能 PHP 框架,今天我来测试下 MixPHP 能否可以挑战C扩展框架 Phalcon。

环境

虚拟机: 4 核,1G
使用 ab 工具压测,命令:ab -n 10000 -c 300 URL

Phalcon

Apache worker模式,mpm配置如下:

<IfModule worker.c>
ServerLimit  50
ThreadLimit  200
StartServers  5
MaxClients  5000
MinSpareThreads  25
MaxSpareThreads  500
ThreadsPerChild  100
MaxRequestsPerChild 0
</IfModule>

用最简单的方式搭建 Phalcon 框架,没有加入任何其他依赖,只注册了一下路由与命名空间。

默认控制器代码如下,输出一个 Hello World。

public function indexAction()
{
    echo 'Hello World';
}

MixPHP

默认控制器代码如下,输出一个 Hello World。

public function actionIndex()
{
    return 'Hello World';
}

开始测试

首先测试 Phalcon,QPS: 968.31

C:\Server\apache24vc11\bin>ab -n 10000 -c 300 http://www.p.com/
This is ApacheBench, Version 2.3 <$Revision: 1757674 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking www.p.com (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests


Server Software:        Apache/2.2.32
Server Hostname:        www.p.com
Server Port:            80

Document Path:          /
Document Length:        11 bytes

Concurrency Level:      300
Time taken for tests:   10.327 seconds
Complete requests:      10000
Failed requests:        0
Total transferred:      2040000 bytes
HTML transferred:       110000 bytes
Requests per second:    968.31 [#/sec] (mean)
Time per request:       309.819 [ms] (mean)
Time per request:       1.033 [ms] (mean, across all concurrent requests)
Transfer rate:          192.90 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    1   0.6      1      22
Processing:    11  304  30.5    308     370
Waiting:        5  177  84.4    180     354
Total:         12  304  30.5    309     371

Percentage of the requests served within a certain time (ms)
  50%    309
  66%    312
  75%    314
  80%    315
  90%    317
  95%    320
  98%    323
  99%    326
 100%    371 (longest request)

然后测试 MixPHP,QPS: 1263.34

C:\Server\apache24vc11\bin>ab -n 10000 -c 300 http://www.v.com:9501/
This is ApacheBench, Version 2.3 <$Revision: 1757674 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking www.v.com (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests


Server Software:        swoole-http-server
Server Hostname:        www.v.com
Server Port:            9501

Document Path:          /
Document Length:        12 bytes

Concurrency Level:      300
Time taken for tests:   7.916 seconds
Complete requests:      10000
Failed requests:        0
Total transferred:      1600000 bytes
HTML transferred:       120000 bytes
Requests per second:    1263.34 [#/sec] (mean)
Time per request:       237.465 [ms] (mean)
Time per request:       0.792 [ms] (mean, across all concurrent requests)
Transfer rate:          197.40 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    1   0.4      1       4
Processing:    12  234  26.3    239     261
Waiting:        6  139  65.5    140     259
Total:         12  235  26.4    240     262

Percentage of the requests served within a certain time (ms)
  50%    240
  66%    243
  75%    246
  80%    247
  90%    252
  95%    254
  98%    258
  99%    259
 100%    262 (longest request)

结论

Phalcon 与 MixPHP 做 Hello World 输出就已经差异这么多 QPS,项目开发中各种数据库操作,各种分层封装,QPS 上的差异还会进一步拉开距离。

不信?你也来测试一下吧,https://github.com/mixstart/mixphp

ITEM DESC
Phalcon 968.31 QPS
MixPHP 1263.34 QPS
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 135,269评论 19 139
  • PHP 性能最好的应该就是原生代码了吧,真的么?MixPHP 是基于 Swoole 扩展的高性能 PHP 框架,今...
    撸代码的乡下人阅读 1,329评论 1 1
  • 先问问自己的心,自己想过什么样的生活。 今天又和女儿在吵架,因为吃饭的问题。 我自己还有一个问题,花的心思太多,在...
    lygly9阅读 168评论 0 0
  • 对你有无限的眷恋 爱情向我走来 可我的心却惴惴不安 在甜蜜中痛苦 在苦闷中甜蜜 你是风, 带我一路欢歌 你是雨, ...
    A小天鹅阅读 211评论 0 3
  • 我应该是吃饱了撑的 九点多和舍友在宿舍里点黄焖鸡的外卖,吃完撑起,她剩下很多土豆片我一粒米不剩下。 一些情绪如鲠在...
    桃子酱呀阅读 178评论 0 0