当前位置: 首页 > 编程笔记 >

MixPHP、Yii和CodeIgniter的并发压力测试小结

司徒捷
2023-03-14
本文向大家介绍MixPHP、Yii和CodeIgniter的并发压力测试小结,包括了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)

2、测试 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)

3、测试 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

总结

以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作具有一定的参考学习价值,如果有疑问大家可以留言交流,谢谢大家对小牛知识库的支持。

 类似资料:
  • 概述 Web压力测试 工具 LoadRunner LoadRunner是一种预测系统行为和性能的负载测试工具,通过模拟实际用户的操作行为进行实时性能监测,来帮助测试人员更快的查找和发现问题。LoadRunner适用于各种体系架构,能支持广泛的协议和技术,为测试提供特殊的解决方案。企业通过LoadRunner能最大限度地缩短测试时间,优化性能并加速应用系统的发布周期。 LoadRunner提供了3大

  • APM 厂商「云智慧」是 DaoCloud 的合作伙伴,云智慧提供了用于应用压力测试的产品「压测宝」,可供 DaoCloud 上部署的应用进行分布式压力测试。以下内容由云智慧公司提供。 压测宝介绍 云智慧压测宝: 自动化全链路云测试,模拟真实压力 压测宝可以利用全球的云资源,快速灵活地部署测试,使任何客户都可以根据需求进行互联网和移动应用的性能测试,帮助客户找出系统瓶颈和潜在问题,改善和提升网站品

  • 测试环境: 系统:debian 6.0 64位 内存:64G cpu:Intel(R) Xeon(R) CPU E5-2420 0 @ 1.90GHz (2颗物理cpu,6核心,2线程) Workerman:开启200个Benchark进程 压测脚本:benchmark 业务:发送并返回hello字符串 普通PHP(版本5.3.10)压测 短连接(每次请求完成后关闭连接,下次请求建立新的连接):

  • 本文向大家介绍压力测试和负载测试的区别相关面试题,主要包含被问及压力测试和负载测试的区别时的应答技巧和注意事项,需要的朋友参考一下 负载测试是模拟实际软件系统所承受的负载条件的系统负荷,通过不断加载(如逐渐增加模拟用户的数量)或其它加载方式来观察不同负载下系统的响应时间和数据吞吐量、系统占用的资源(如CPU、内存)等,以检验系统的行为和特性,以发现系统可能存在的性能瓶颈、内存泄漏、不能实时同步等问

  • 测试环境: 系统:debian 6.0 64位 内存:64G cpu:Intel(R) Xeon(R) CPU E5-2420 0 @ 1.90GHz (2颗物理cpu,6核心,2线程) Workerman:开启200个Benchark进程 压测脚本:benchmark 业务:发送并返回hello字符串 普通PHP(版本5.3.10)压测 短链接(每次请求完成后关闭链接,下次请求建立新的链接):

  • 本文向大家介绍Apache ab并发负载压力测试实现方法,包括了Apache ab并发负载压力测试实现方法的使用技巧和注意事项,需要的朋友参考一下 ab命令原理 Apache的ab命令模拟多线程并发请求,测试服务器负载压力,也可以测试nginx、lighthttp、IIS等其它Web服务器的压力。 ab命令对发出负载的计算机要求很低,既不会占用很多CPU,也不会占用太多的内存,但却会给目标服务器造