這篇文章主要為大家詳細(xì)介紹了PHP7.0與PHP5.6下Laravel博客的應(yīng)用性能對(duì)比,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下。
成都創(chuàng)新互聯(lián)從2013年創(chuàng)立,先為義烏等服務(wù)建站,義烏等地企業(yè),進(jìn)行企業(yè)商務(wù)咨詢服務(wù)。為義烏企業(yè)網(wǎng)站制作PC+手機(jī)+微官網(wǎng)三網(wǎng)同步一站式服務(wù)解決您的所有建站問題。
目前我安裝的 Homestead 虛擬機(jī)版本是 2.1.8:
該版本 Homestead 上預(yù)裝的 PHP 版本是 5.6.15:
我們使用 ab 命令(Apache 提供的性能測(cè)試工具)在該版本中測(cè)試 Laravel 應(yīng)用(以目前正在講的使用Laravel開發(fā)的博客應(yīng)用為例)性能,我們模擬 10000 次請(qǐng)求,100 個(gè)并發(fā)進(jìn)行壓力測(cè)試:
ab -n 10000 -c 100 http://blog.app/
運(yùn)行結(jié)果如下:
This is ApacheBench, Version 2.3 Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Licensed to The Apache Software Foundation, http://www.apache.org/ Benchmarking blog.app (be patient) Completed 1000 requests Completed 2000 requests Completed 3000 requests Completed 4000 requests Completed 5000 requests Completed 6000 requests Completed 7000 requests Completed 8000 requests Completed 9000 requests Completed 10000 requests Finished 10000 requests Server Software: nginx/1.8.0 Server Hostname: blog.app Server Port: 80 Document Path: / Document Length: 324 bytes Concurrency Level: 100 Time taken for tests: 69.354 seconds Complete requests: 10000 Failed requests: 0 Total transferred: 19851388 bytes HTML transferred: 10230000 bytes Requests per second: 144.19 [#/sec] (mean) Time per request: 693.545 [ms] (mean) Time per request: 6.935 [ms] (mean, across all concurrent requests) Transfer rate: 279.52 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 0 0 0.2 0 3 Processing: 17 684 319.1 588 2720 Waiting: 17 684 319.1 588 2720 Total: 20 684 319.1 588 2720 Percentage of the requests served 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)
這里我們要關(guān)注的是紅色加粗的文字,即每秒處理請(qǐng)求數(shù),這是衡量系統(tǒng)性能的關(guān)鍵指標(biāo)。根據(jù)系統(tǒng)及硬件配置的差異,數(shù)據(jù)會(huì)有些出入。
現(xiàn)在我們按照“Laravel Homestead 支持 PHP 7 ”這一節(jié)所述將 Homestead 中的 PHP 升級(jí)到 7.0 版本。
使用 vagrant ssh 登錄到新添加的 homestead-7 虛擬機(jī),查看 PHP 版本信息是否正確:
此時(shí)在瀏覽器中訪問 http://blog.app 會(huì)報(bào)錯(cuò),因?yàn)樾掳惭b的 Homestead 數(shù)據(jù)庫(kù)數(shù)據(jù)為空,需要登錄到虛擬機(jī)運(yùn)行如下命令運(yùn)行遷移并填充數(shù)據(jù):
php artisan migrate php artisan db:seed
再次訪問就OK了,好了我們繼續(xù)使用同樣的 ab 命令進(jìn)行壓力測(cè)試:
ab -n 10000 -c 100 http://blog.app/
運(yùn)行結(jié)果如下:
This is ApacheBench, Version 2.3 Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Licensed to The Apache Software Foundation, http://www.apache.org/ Benchmarking blog.app (be patient) Completed 1000 requests Completed 2000 requests Completed 3000 requests Completed 4000 requests Completed 5000 requests Completed 6000 requests Completed 7000 requests Completed 8000 requests Completed 9000 requests Completed 10000 requests Finished 10000 requests Server Software: nginx/1.8.0 Server Hostname: blog.app Server Port: 80 Document Path: / Document Length: 324 bytes Concurrency Level: 100 Time taken for tests: 45.032 seconds Complete requests: 10000 Failed requests: 0 Total transferred: 20101202 bytes HTML transferred: 10230000 bytes Requests per second: 222.06 [#/sec] (mean) Time per request: 450.319 [ms] (mean) Time per request: 4.503 [ms] (mean, across all concurrent requests) Transfer rate: 435.91 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 0 0 0.2 0 4 Processing: 11 443 252.8 379 1978 Waiting: 11 443 252.8 379 1978 Total: 15 443 252.8 379 1978 Percentage of the requests served 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)
經(jīng)過對(duì)比,同一個(gè) Laravel 應(yīng)用在 PHP 7.0 下的性能比 PHP 5.6 提高了54%,這是一個(gè)很顯著的性能提升,當(dāng)然環(huán)境不同數(shù)據(jù)會(huì)有所出入,而且還有更大的提升空間。
以上就是關(guān)于PHP7.0與PHP5.6下Laravel博客應(yīng)用性能對(duì)比分析詳解的詳細(xì)內(nèi)容,更多請(qǐng)關(guān)注創(chuàng)新互聯(lián)其它相關(guān)文章!
網(wǎng)站名稱:PHP7.0與PHP5.6下Laravel博客的應(yīng)用性能對(duì)比介紹
分享網(wǎng)址:http://aaarwkj.com/article40/jeedho.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供全網(wǎng)營(yíng)銷推廣、電子商務(wù)、網(wǎng)站排名、企業(yè)建站、網(wǎng)站策劃、商城網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)