PHP開啟opcache提升代碼效能,php開啟opcache代碼_PHP教程

來源:互聯網
上載者:User

PHP開啟opcache提升代碼效能,php開啟opcache代碼


配置指令如下:

[opcache]zend_extension=opcache.soopcache.enable_cli=1;共用記憶體大小, 這個根據你們的需求可調opcache.memory_consumption=256   ;interned string的記憶體大小, 也可調opcache.interned_strings_buffer=8;最大緩衝的檔案數目opcache.max_accelerated_files=4000;60s檢查一次檔案更新opcache.revalidate_freq=60;開啟快速關閉, 開啟這個在PHP Request Shutdown的時候 會收記憶體的速度會提高opcache.fast_shutdown=1;不儲存檔案/函數的注釋opcache.save_comments=0 

實際效能對比:

下面是實際測試中沒有開啟opcache的資料:

[root@localhost ~]# ab -n 10000 -c 200 "http://112.126.69.14/main.php?a=Role&m=createRole"This is ApacheBench, Version 2.3 <$Revision: 655654 $>Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/Licensed to The Apache Software Foundation, http://www.apache.org/Benchmarking 112.126.69.14 (be patient)Completed 1000 requestsCompleted 2000 requestsCompleted 3000 requestsCompleted 4000 requestsCompleted 5000 requestsCompleted 6000 requestsCompleted 7000 requestsCompleted 8000 requestsCompleted 9000 requestsCompleted 10000 requestsFinished 10000 requestsServer Software:    openresty/1.7.2.1Server Hostname:    112.126.69.14Server Port:      80Document Path:     /main.php?a=Role&m=createRoleDocument Length:    2 bytesConcurrency Level:   200Time taken for tests:  26.061 secondsComplete requests:   10000Failed requests:    20  (Connect: 0, Receive: 0, Length: 20, Exceptions: 0)Write errors:      0Non-2xx responses:   20Total transferred:   1713580 bytesHTML transferred:    23520 bytesRequests per second:  383.72 [#/sec] (mean)Time per request:    521.216 [ms] (mean)Time per request:    2.606 [ms] (mean, across all concurrent requests)Transfer rate:     64.21 [Kbytes/sec] receivedConnection Times (ms)       min mean[+/-sd] median  maxConnect:    2  3  3.2   2   60Processing:  17 461 905.0  219  16496Waiting:    17 461 904.9  219  16496Total:     21 464 905.0  222  16502Percentage of the requests served within a certain time (ms) 50%  222 66%  271 75%  369 80%  412 90%  805 95%  1248 98%  2597 99%  3489 100% 16502 (longest request)

開啟之後的資料:

[root@localhost ~]# ab -n 10000 -c 200 "http://112.126.69.14/main.php?a=Role&m=createRole"This is ApacheBench, Version 2.3 <$Revision: 655654 $>Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/Licensed to The Apache Software Foundation, http://www.apache.org/Benchmarking 112.126.69.14 (be patient)Completed 1000 requestsCompleted 2000 requestsCompleted 3000 requestsCompleted 4000 requestsCompleted 5000 requestsCompleted 6000 requestsCompleted 7000 requestsCompleted 8000 requestsCompleted 9000 requestsCompleted 10000 requestsFinished 10000 requestsServer Software:    openresty/1.7.2.1Server Hostname:    112.126.69.14Server Port:      80Document Path:     /main.php?a=Role&m=createRoleDocument Length:    2 bytesConcurrency Level:   200Time taken for tests:  14.237 secondsComplete requests:   10000Failed requests:    0Write errors:      0Total transferred:   1711710 bytesHTML transferred:    20020 bytesRequests per second:  702.40 [#/sec] (mean)Time per request:    284.739 [ms] (mean)Time per request:    1.424 [ms] (mean, across all concurrent requests)Transfer rate:     117.41 [Kbytes/sec] receivedConnection Times (ms)       min mean[+/-sd] median  maxConnect:    2  66 272.6   2  3005Processing:   4 176 666.4   6  9026Waiting:    4 163 642.8   6  9026Total:     6 242 745.7   9  10028Percentage of the requests served within a certain time (ms) 50%   9 66%   14 75%   99 80%  122 90%  1006 95%  1476 98%  2853 99%  3543 100% 10028 (longest request)

以上所述就是本文的全部內容,希望大家能夠喜歡。

http://www.bkjia.com/PHPjc/989868.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/989868.htmlTechArticlePHP開啟opcache提升代碼效能,php開啟opcache代碼 配置指令如下: [opcache]zend_extension=opcache.soopcache.enable_cli=1;共用記憶體大小, 這個根據你們的需求...

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.