PHP Open Opcache Improve code performance

Source: Internet
Author: User
Tags apc min connect server port

PHP Open Opcache improve code performance

APC is the best performing code cache in PHP5.4 and the following versions. However, after the PHP upgrade to 5.5 and above, the APC is no longer valid. You need to use the Zend Opcache extension.

The configuration directives are as follows:

?

1 2 3 4, 5 6 7 8 9 10 11 12 13 14 15 [Opcache] zend_extension=opcache.so opcache.enable_cli=1, shared memory size, which can be adjusted according to your needs opcache.memory_consumption=256; Interned string's memory size, also adjustable opcache.interned_strings_buffer=8; The maximum number of cached files opcache.max_accelerated_files=4000; 60s Check for file update opcache.revalidate_freq=60; Turn on fast shutdown, open this shutdown the speed of the memory will be increased when PHP Request is opcache.fast_shutdown=1; do not save the file /function Annotation Opcache.save_comments=0

Actual Performance comparison:

Here is the data that does not open Opcache in the actual test:

?

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 This is the same as the [root@localhost ~]# ab-n 10000-c "Http://112.126.69.14/main.php?a=Role&m=createRole" This is apachebench, vers Ion 2.3 < $Revision: 655654 $> Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/Licensed to T He Apache Software Foundation, http://www.apache.org/  Benchmarking 112.126.69.14 (Be patient) Completed 1000 TS Completed 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:openresty/1.7.2.1 Server hostname:112.126.69.14 server port:80   Document Path:/main.php?a =Role&m=createrole Document length:2 bytes   Concurrency level:200 time taken for tests:26.061 seconds requests:10000 Failed requests:20 (connect:0, receive:0, length:20, exceptions:0) Write errors:0 non-2xx : Total transferred:1713580 bytes HTML transferred:23520 bytes Requests/second:383.72 [#/sec] (mean) time per re quest:521.216 [MS] (mean) time/request:2.606 [MS] (mean, across all concurrent requests) Transfer rate:64.21 [Kbyte S/SEC] Received   Connection times (ms) min MEAN[+/-SD] Median max Connect:2 3 3.2 2 processing:17 461 905.0 219 16496 waiting:17 461 904.9 219 16496 total:21 464 905.0 222 16502   Percentage of the requests served within a CER Tain Time (MS) 50% 222 66% 271 75% 369 80% 412 90% 805 1248 98% 2597 99% 3489 100% 16502 (longest request)

After the data is opened:

?

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 The [root@localhost ~]# ab-n 10000-c "Http://112.126.69.14/main.php?a=Role&m=createRole" This is apachebench, vers Ion 2.3 < $Revision: 655654 $> Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/Licensed to T He Apache Software Foundation, http://www.apache.org/  Benchmarking 112.126.69.14 (Be patient) Completed 1000 TS Completed 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:openresty/1.7.2.1 server hostname:112.126.69.14 server port:80   Document Path:/mai n.phP?a=role&m=createrole Document length:2 bytes   Concurrency level:200 time taken for tests:14.237 seconds Lete requests:10000 Failed requests:0 Write errors:0 total transferred:1711710 bytes HTML transferred:20020 bytes Uests per second:702.40 [#/sec] (mean) time/request:284.739 [MS] (mean) time per request:1.424 [MS] (mean, across a ll concurrent requests) Transfer rate:117.41 [kbytes/sec] received   Connection times (ms) min MEAN[+/-SD] Median MA X connect:2 272.6 2 3005 processing:4 176 666.4 6 9026 waiting:4 163 642.8 6 9026 total:6 242 745.7 9 10028   Percentage of the requests served within a certain time (ms) 50% 9 66% 14 75% 99 80% 122 90% 1006 95% 1476 98% 2853 99% 35 100% 10028 (Longest request)

The above is the entire content of this article, I hope you can enjoy.

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.