美文网首页ThinkPHPMixPHP 碎片学习Laravel开发实践
MixPHP/Yii/CodeIgniter 并发压力测试

MixPHP/Yii/CodeIgniter 并发压力测试

作者: 撸代码的乡下人 | 来源:发表于2017-10-13 10:30 被阅读226次

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

相关文章

  • MixPHP/Yii/CodeIgniter 并发压力测试

    MixPHP 是一个基于 Swoole 的高性能框架,CodeIgniter 是一个元老级的轻量级框架,Yii 是...

  • Yii/CodeIgniter/Phalcon/MixPHP 基

    测试环境 硬件环境(虚拟机): 4核 1G 运行环境: Nginx 8 进程 ,PHP-FPM 静态模式 8进程,...

  • MixPHP 与 Phalcon 并发压力测试

    说起 PHP 高性能框架,一定会有人说 Yaf/Phalcon,这两个C扩展类型的框架基本是高性能框架的代表了,而...

  • MixPHP 与原生 PHP 并发压力测试

    PHP 性能最好的应该就是原生代码了吧,真的么?MixPHP 是基于 Swoole 扩展的高性能 PHP 框架,今...

  • MixPHP 与原生 Swoole 并发压力测试

    MixPHP 是基于 Swoole 的高性能框架,封装后比原生 Swoole 对比损失了多少性能呢?今天我们来测试...

  • 框架

    tp3.2 tp5.0ci2.0 3.1.3 http://codeigniter.org.cn/yii2.1...

  • MixPHP 独特的SQL构建方式

    独特的SQL构建方式 MixPHP 对CUD这些写操作都有专用方法,可快速构建,使用方法也与 Yii2 完全一至,...

  • MixPHP 并发性能全面对比测试

    MixPHP 框架代码只有几千行,理论上在性能方面应该超过各种同步类传统流行框架,我更希望大家能自己去测试,毕竟我...

  • ab并发压力测试

    在Windows系统下,打开cmd命令行窗口,定位到apache安装目录的bin目录下 cd C:\Program...

  • Nginx Tomcat集群配置

    并发访问 对于服务器来说,大量的并发访问容易造成服务器宕机 并发访问性能测试 可以通过压力测试来检查高并发访问的性...

网友评论

  • 该叶无法找到:还没有看代码,不过比CI快这么多?Benchmark我认为不是PHP届最重要的指标。不过我还是支持的,希望作者了解造轮子要背负的责任:stuck_out_tongue_winking_eye:
    撸代码的乡下人:@该叶无法找到 所以我希望大家去使用,才知道框架质量到底如何?也能一起完善TA。

本文标题:MixPHP/Yii/CodeIgniter 并发压力测试

本文链接:https://www.haomeiwen.com/subject/wzgayxtx.html