MixPHP/Yii/CodeIgniter 并发压力测试

MixPHP 是一个基于 Swoole 的高性能框架,CodeIgniter 是一个元老级的轻量级框架,Yii 是一个非常流行的框架,以下是三个框架的对比。

由于 Yii/CodeIgniter 是基于 Apache/PHP-FPM 的传统框架,如果使用 MixPHP 的正常 Swoole 部署方式来对比,显得有些不公平,由于 MixPHP 同时支持在 Apache/PHP-FPM 中运行,所以此次测试的 MixPHP 是部署在 Apache 之中。

环境

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

Yii

Yii 关闭了 debug,并设置为 pro 环境。

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

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

CodeIgniter

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

<?php
public function index()
{
    echo 'Hello World';
}

MixPHP

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

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

开始测试

  1. 测试 Yii,QPS: 56.40
C:\Server\apache24vc11\bin>ab -n 5000 -c 100 http://www.b.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.b.com (be patient)
Completed 500 requests
Completed 1000 requests
Completed 1500 requests
Completed 2000 requests
Completed 2500 requests
Completed 3000 requests
Completed 3500 requests
Completed 4000 requests
Completed 4500 requests
Completed 5000 requests
Finished 5000 requests


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

Document Path:          /
Document Length:        9 bytes

Concurrency Level:      100
Time taken for tests:   88.659 seconds
Complete requests:      5000
Failed requests:        0
Total transferred:      1080000 bytes
HTML transferred:       45000 bytes
Requests per second:    56.40 [#/sec] (mean)
Time per request:       1773.170 [ms] (mean)
Time per request:       17.732 [ms] (mean, across all concurrent requests)
Transfer rate:          11.90 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   1.0      1      29
Processing:    14 1765 4200.5    688   48084
Waiting:       14 1610 3741.9    682   46690
Total:         14 1766 4200.5    688   48084
WARNING: The median and mean for the initial connection time are not within a normal deviation
        These results are probably not that reliable.

Percentage of the requests served within a certain time (ms)
  50%    688
  66%   1087
  75%   1400
  80%   1657
  90%   3029
  95%   7665
  98%  14760
  99%  24300
 100%  48084 (longest request)
  1. 测试 CodeIgniter ,QPS: 144.42
C:\Server\apache24vc11\bin>ab -n 5000 -c 100 http://www.c.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.c.com (be patient)
Completed 500 requests
Completed 1000 requests
Completed 1500 requests
Completed 2000 requests
Completed 2500 requests
Completed 3000 requests
Completed 3500 requests
Completed 4000 requests
Completed 4500 requests
Completed 5000 requests
Finished 5000 requests


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

Document Path:          /
Document Length:        8 bytes

Concurrency Level:      100
Time taken for tests:   34.621 seconds
Complete requests:      5000
Failed requests:        0
Total transferred:      1075000 bytes
HTML transferred:       40000 bytes
Requests per second:    144.42 [#/sec] (mean)
Time per request:       692.419 [ms] (mean)
Time per request:       6.924 [ms] (mean, across all concurrent requests)
Transfer rate:          30.32 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.7      1      22
Processing:     8  689 1014.3    480   13324
Waiting:        8  686 1012.2    478   13324
Total:          9  689 1014.3    480   13325
WARNING: The median and mean for the initial connection time are not within a normal deviation
        These results are probably not that reliable.

Percentage of the requests served within a certain time (ms)
  50%    480
  66%    673
  75%    810
  80%    902
  90%   1238
  95%   1808
  98%   3336
  99%   6037
 100%  13325 (longest request)
  1. 测试 MixPHP,QPS: 440.48
C:\Server\apache24vc11\bin>ab -n 5000 -c 100 http://www.a.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.a.com (be patient)
Completed 500 requests
Completed 1000 requests
Completed 1500 requests
Completed 2000 requests
Completed 2500 requests
Completed 3000 requests
Completed 3500 requests
Completed 4000 requests
Completed 4500 requests
Completed 5000 requests
Finished 5000 requests


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

Document Path:          /
Document Length:        12 bytes

Concurrency Level:      100
Time taken for tests:   11.351 seconds
Complete requests:      5000
Failed requests:        0
Total transferred:      1025000 bytes
HTML transferred:       60000 bytes
Requests per second:    440.48 [#/sec] (mean)
Time per request:       227.026 [ms] (mean)
Time per request:       2.270 [ms] (mean, across all concurrent requests)
Transfer rate:          88.18 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    1   0.9      1      25
Processing:     4  222 822.4     15   10376
Waiting:        4  221 822.4     14   10376
Total:          4  222 822.4     16   10376

Percentage of the requests served within a certain time (ms)
  50%     16
  66%     69
  75%    214
  80%    364
  90%    561
  95%    762
  98%    978
  99%   1829
 100%  10376 (longest request)

结论

虚拟机文件IO性能太差,Yii 做300并发直接不响应,只好降低到100并发数,同样架构的测试结果 MixPHP 领先。

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

ITEM DESC
Yii 56.40 QPS
CodeIgniter 144.42 QPS
MixPHP 440.48 QPS
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 162,475评论 4 372
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 68,744评论 2 307
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 112,101评论 0 254
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 44,732评论 0 221
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 53,141评论 3 297
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 41,049评论 1 226
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 32,188评论 2 320
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 30,965评论 0 213
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 34,716评论 1 250
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 30,867评论 2 254
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 32,341评论 1 265
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 28,663评论 3 263
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 33,376评论 3 244
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 26,200评论 0 8
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 26,990评论 0 201
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 36,179评论 2 285
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 35,979评论 2 279

推荐阅读更多精彩内容