首页 > 作文

关于PHP7.0与PHP5.6下Laravel博客应用性能对比分析详解

更新时间:2023-04-08 13:02:05 阅读: 评论:0

目前我安装的 homestead 虚拟机版本是 2.1.8:
该版本 homestead 上预装的 php 版本是 5.6.15: 我们使用 ab 命令(apache 提供的性能测试工具)在该版本中测试 laravel 应用(以目前正在讲的使用laravel开发的博客应用为例)性能,我们模拟 10000 次请求,100 个并发进行压力测试:

ab -n 10000 -c 100 http://blog.app/

  

运行结果如下:

this is apachebench, version 2.3 copyright 1996 adam twiss, zeus technology ltd, http://www.zeustech.net/licend to the apache software foundation, http://www.apache.org/ benchmarking blog.app (be patient)completed 1000 requestscompleted 2000 requestscompleted 3000 requestscompleted 4000 requestscompleted如何提高写作能力 5000 requestscompleted 6000 requestscompleted 7000 requestscompleted 8000 requestscompleted 9000 requestscompleted 10000 requestsfinished 10000 requestsrver software: nginx/1.8.0rver hostname: blog.apprver port: 80 document path: /document length: 324 bytes concurrency level: 100time taken for tests: 69.354 condscomplete requests: 10000failed requests: 0total transferred: 19851388 byteshtml transferred: 10230000 bytesrequests per cond: 144.19 [#/c] (mean)time per request: 693.545 [ms] (mean)time per request: 6.935 [ms] (mean, across all concurrent requests)transfer rate: 279.52 [kbytes/c] received connection times (ms)                  min  mean[+/-sd]  median  maxconnect:       0       0     0.2                 0      3processing: 17    6知道用英语怎么说84   319.1           588   2720waiting:      17     684  花朵连连看 319.1           588   2720total:          20     684   319.1           588   2720 percentage of the requests rved within a certain time (ms) 50%      588 66%      695 75%      842 80%      933 90%    1155 95%    1321 98%    1545 99%    1813 100%  2720 (longest request)

  

这里我们要关注的是红色加粗的文字,即每秒处理请求数,这是衡量系统性能的关键指标。根据系统及硬件配置的差异,数据会有些出入。 现在我们按照“laravel homestead 支持 php 7 ”这一节所述将 homestead 中的 php 升级到 7.0 版本。 使用 vagrant ssh 登录到新添加的 homestead-7 虚拟机,查看 php 版本信息是否正确: 此时在浏览器中访问 http://blog.app 会报错,因为新安装的 homestead 数据库数据为空,需要登录到虚拟机运行如下命令运行迁移并填充数据:

php artisan migrate php artisan db:ed

  

再次访问就ok了,好了我们继续使用同样的 ab 命令进行压力测试:

ab -n 10000 -c 100 http://blog.app/ 

  

运行结果如下:

this is apachebench, version 2.3 copyright 1996 adam twiss, zeus technology ltd, http://www.zeustech.net/licend to the apache software foundation, http://www.apache.org/ benchmarking blog.app (be patient)completed 1000 requestscompleted 2000 requestscompleted 3000 requestscompleted 4000 requestscompleted 5000 requestscompleted 6000 requestscompleted 7000 requestscompleted 8000 requestscompleted 9000 requestscompleted 10000 requestsfinished 10000 requestsrver software: nginx/1.8.0rver hostname: blog.apprver port: 80 document path: /document length: 324 人参果总皂苷的功效bytes concurrency level: 100time taken for tests: 45.032 condscomplete requests: 10000failed requests: 0total transferred: 20101202 byteshtml transferred: 10230000 bytesrequests per cond: 222.06 [#/c] (mean)time per request: 450.319 [ms] (mean)time per request: 4.503 [ms] (mean, across all concurrent requests)transfer rate: 435.91 [kbytes/c] received connection times (ms) min  mean[+/-sd]  median   maxconnect:       0       0     0.2                 0       4pro三级英语作文cessing: 11    443   252.8           379   1978waiting:      11     443   252.8           379   1978total:          15     443   252.8           379   1978 percentage of the requests rved within a certain time (ms) 50%      379 66%      517 75%      590 80%      631 90%      795 95%      938 98%    1060 99%    1229 100%  1978 (longest request)

  

经过对比,同一个 laravel 应用在 php 7.0 下的性能比 php 5.6 提高了54%,这是一个很显著的性能提升,当然环境不同数据会有所出入,而且还有更大的提升空间。

更多学习内容请访问:

腾讯t3-t4标准精品php架构师教程目录大全,只要你看完保证薪资上升一个台阶(持续更新)​

本文发布于:2023-04-08 12:59:04,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/zuowen/d1ca14b1e8f48b885a158d18235d270f.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

本文word下载地址:关于PHP7.0与PHP5.6下Laravel博客应用性能对比分析详解.doc

本文 PDF 下载地址:关于PHP7.0与PHP5.6下Laravel博客应用性能对比分析详解.pdf

标签:版本   性能   数据   虚拟机
相关文章
留言与评论(共有 0 条评论)
   
验证码:
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图