php yaf swoole,韩天峰(Rango)的博客

本次压测使用的是一台4核I5 CPU,8G内存的笔记本。使用的版本是:

swoole_framework github最新版

Yaf 2.2.9

Yii-1.1.14

php-fpm和swoole应用服务器均启用了8个进程,因为仅比较hello world,不存在阻塞,8进程足以压满CPU。php5-fpm中已经启用了apc对所有PHP进行缓存。

压测使用ab工具,参数为:

ab -c 100 -n 10000

Yaf

Server Software: nginx/1.2.6

Server Hostname: localhost

Server Port: 80

Document Path: /yafapp/

Document Length: 11 bytes

Concurrency Level: 100

Time taken for tests: 1.336 seconds

Complete requests: 10000

Failed requests: 0

Write errors: 0

Total transferred: 1770000 bytes

HTML transferred: 110000 bytes

Requests per second: 7486.03 [#/sec] (mean)

Time per request: 13.358 [ms] (mean)

Time per request: 0.134 [ms] (mean, across all concurrent requests)

Transfer rate: 1293.97 [Kbytes/sec] received

Yii

Server Software: nginx/1.2.6

Server Hostname: localhost

Server Port: 80

Document Path: /yiiapp/

Document Length: 11 bytes

Concurrency Level: 100

Time taken for tests: 8.016 seconds

Complete requests: 10000

Failed requests: 0

Write errors: 0

Total transferred: 1770000 bytes

HTML transferred: 110000 bytes

Requests per second: 1247.55 [#/sec] (mean)

SwooleFramework

Server Software: Swoole

Server Hostname: 127.0.0.1

Server Port: 8888

Document Path: /hello/index

Document Length: 11 bytes

Concurrency Level: 100

Time taken for tests: 1.470 seconds

Complete requests: 10000

Failed requests: 0

Write errors: 0

Total transferred: 2750000 bytes

HTML transferred: 110000 bytes

Requests per second: 6801.78 [#/sec] (mean)

Time per request: 14.702 [ms] (mean)

Time per request: 0.147 [ms] (mean, across all concurrent requests)

Transfer rate: 1826.65 [Kbytes/sec] receive

结果评价

有些人说框架的消耗和业务逻辑相比不算什么,这句话在你的QPS不到10个时是完全正确的。但如果你的网站访问量很大,机器负载很高,那么框架的性能消耗就会很明显的体现出来了。

Yii压测只有1200QPS,假设网站的平均QPS为200,因为框架的消耗是纯CPU消耗,也就是光Yii就会带来(200/1200)*100%=16.7%的CPU消耗。而Yaf/Swoole的QPS可达7000,200qps仅占用

(200/7000)*100%=2.8%的CPU消耗。当然200QPS对于一个巨型网站来说只是一个小数目,框架的CPU消耗会随着QPS增加而直线上升。

Swoole框架的早期版本可达9000QPS,swoole框架本身还是很复杂的,因为全部是PHP的代码实现,仅底层使用了swoole扩展,如果做了足够的精简和优化,还是有很大的上升空间。

压测证明Yaf的性能非常好。如果你希望使用PHP应用服务器可以选择Swoole,如果是LAMP/LNMP架构可以使用Yaf框架。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值