继续浏览精彩内容
慕课网APP
程序员的梦工厂
打开
继续
感谢您的支持,我会继续努力的
赞赏金额会直接到老师账户
将二维码发送给自己后长按识别
微信支付
支付宝支付

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

Pizzaaa
关注TA
已关注
手记 23
粉丝 77
获赞 47

小框架的代码从一开始就尽量使用单例模式,它的优点就是不会被重复多次实例化。能减少内存滥用。在关闭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项目。有兴趣的小伙伴可以继续关注。

打开App,阅读手记
2人推荐
发表评论
随时随地看视频慕课网APP