PHP improves performance with Opcache

Source: Internet
Author: User
Tags apc apc 4
APC is the best-performing code cache in PHP5.4 and below. However, when PHP is upgraded to 5.5 and above, APC is no longer valid. Need to use Zend's opcache extension. This article will share the Opcache configuration example, we hope to help you.

The configuration directives are as follows:

[Opcache]zend_extension=opcache.soopcache.enable_cli=1; shared memory size, this can be adjusted according to your needs opcache.memory_consumption=256   ; Interned string memory size, also adjustable opcache.interned_strings_buffer=8; The maximum number of cached files opcache.max_accelerated_files=4000; 60s Check the file update opcache.revalidate_freq=60; Open Quick Close, open this in PHP Request shutdown time will collect memory speed will increase opcache.fast_shutdown=1; do not save the file /Function Comment Opcache.save_comments=0

Actual Performance comparison:

The following is the data that is not open opcache in the actual test:

[Root@localhost ~]# ab-n 10000-c "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 requestscompleted requestscompleted 4000 requestscompleted 6000 requestscompleted 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 secondsComple  Te 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 Reque st: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 9 04.9 219 16496total:21 464 905.0 222 16502Percentage of the requests served within a certain time (ms) 50% 222 6 6% 271 75% 369 80% 412 90% 805 95% 1248 98% 2597 99% 3489 100% 16502 (longest request)

After opening the data:

[Root@localhost ~]# ab-n 10000-c "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 requestscompleted requestscompleted 4000 requestscompleted 6000 requestscompleted 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 secondsComple Te requests:10000failed requests:0write errors:0total transferred:1711710 byteshtml transferred:20020 Bytesrequests per second:702.40 [#/sec] (mean) time perrequest:284.739 [MS] (mean) time per request:1.424 [MS] (mean, across all concurrent requests) Transfer Rate:11 7.41 [Kbytes/sec] receivedconnection times (ms) min MEAN[+/-SD] Median maxconnect:2 3005Processi 272.6 2 Ng:4 176 666.4 6 9026waiting:4 163 642.8 6 9026total:6 242 745.7 9 10028Percentage of the requests SE RVed within a certain time (ms) 50% 9 66% 75% 80% 122 90% 1006 95% 1476 98% 2853 99% 3543 100% 10028 (lon Gest request)

Related recommendations:

Differences between Eaccelerator, memcached, XCache, APC 4 acceleration, and cache extensions in PHP

PHP APC Cache and comparison with Redis

PHP Optimization detailed _php tutorial

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.