为了账号安全,请及时绑定邮箱和手机立即绑定

SWOOLE 从入门到放弃之写个小框架(二十一)

标签:
PHP

小框架的代码从一开始就尽量使用单例模式,它的优点就是不会被重复多次实例化。能减少内存滥用。在关闭enable_static_handler后,控制器输出 hello,word
VBOX+CENTOS7 CPU 4CORE MEM 5G

ab -c 100 -n 30000 http://127.0.0.1:9501/

This is ApacheBench, Version 2.3 <$Revision: 1430300 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 127.0.0.1 (be patient)
Completed 3000 requests
Completed 6000 requests
Completed 9000 requests
Completed 12000 requests
Completed 15000 requests
Completed 18000 requests
Completed 21000 requests
Completed 24000 requests
Completed 27000 requests
Completed 30000 requests
Finished 30000 requests

Server Software:        swoole-http-server
Server Hostname:        127.0.0.1
Server Port:            9501

Document Path:          /
Document Length:        46 bytes

Concurrency Level:      100
Time taken for tests:   2.330 seconds
Complete requests:      30000
Failed requests:        0
Write errors:           0
Total transferred:      5820000 bytes
HTML transferred:       1380000 bytes
Requests per second:    12874.83 [#/sec] (mean)
Time per request:       7.767 [ms] (mean)
Time per request:       0.078 [ms] (mean, across all concurrent requests)
Transfer rate:          2439.18 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    1   0.7      1       7
Processing:     1    7   3.1      6      69
Waiting:        0    7   3.1      6      69
Total:          2    8   3.1      7      72

Percentage of the requests served within a certain time (ms)
  50%      7
  66%      8
  75%      8
  80%      9
  90%     10
  95%     11
  98%     14
  99%     18
 100%     72 (longest request)

代码没有优化,只是在写代码时就比较注意。AB压测通达到12K,超出了当时设定的10K。

阶段性的开发算是完成了。接下来,在小框架的机基上编写一个简单的IM项目。有兴趣的小伙伴可以继续关注。

点击查看更多内容
2人点赞

若觉得本文不错,就分享一下吧!

评论

作者其他优质文章

正在加载中
PHP开发工程师
手记
粉丝
77
获赞与收藏
47

关注作者,订阅最新文章

阅读免费教程

感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦
今天注册有机会得

100积分直接送

付费专栏免费学

大额优惠券免费领

立即参与 放弃机会
意见反馈 帮助中心 APP下载
官方微信

举报

0/150
提交
取消