Cache Cache improve phar phar compiler package loading speed

phar file can use the PHP files, all packaged in a single file, the site is very easy to deploy. However, a single file can be used opcache PHP cache (byte code cache), PHP to improve the operating speed. So PHAR package how to use the cache yet.

It should be configured (php.ini)

phar.cache_list

As explained in the manual:

Allows mapping phar archives to be pre-parsed at web server startup, providing a performance improvement that brings running files out of a phar archive very close to the speed of running those files from a traditional disk-based installation.

Pre-analysis allows mapping phar archive at web server startup, thereby providing improved performance, so that the file phar archive very close to running speed from a conventional disk-based installation files run speed.

This feature is available only in phar 2.0.0 started to support. Of course, the current installation of PHP you are 2 or more. phar 2.0.0 release date is 2009-07-29. Manual configuration instructions.

In php.ini # (are windows that):
pharcachelist = C: \ path For \ to \ phar1phar; C: \ path For \ to \ phar2phar
# in php.ini (to unix):
pharcachelist = / path For / to / phar1.phar: /path/to/phar2.phar

Windows on multiple files using a semicolon, a colon on LINUX.

Once you've enabled cache_list, restart php-fpm (or possibly Apache).

Make sure opcache is enabled (php.ini):

opcache.enable=1

So how do you effect? With my NILCMS framework to do the test. surroundings:

PHP 7.2.25

NGINX 1.14.2

CentOS 07/07/1908

Test Command: ab -n 500 -c 5 domain

1.opcache is not enabled, cache_list not configured

Concurrency Level:      5
Time taken for tests:   7.665 seconds
Complete requests:      500
Failed requests:        0
Total transferred:      110500 bytes
HTML transferred:       21000 bytes
Requests per second:    65.23 [#/sec] (mean)
Time per request:       76.648 [ms] (mean)
Time per request:       15.330 [ms] (mean, across all concurrent requests)
Transfer rate:          14.08 [Kbytes/sec] received

2.opcache enabled, cache_list not configured

Concurrency Level:      5
Time taken for tests:   1.406 seconds
Complete requests:      500
Failed requests:        0
Total transferred:      110500 bytes
HTML transferred:       21000 bytes
Requests per second:    355.62 [#/sec] (mean)
Time per request:       14.060 [ms] (mean)
Time per request:       2.812 [ms] (mean, across all concurrent requests)
Transfer rate:          76.75 [Kbytes/sec] received

3.opcache not enabled, cache_list configuration

Concurrency Level:      5
Time taken for tests:   7.588 seconds
Complete requests:      500
Failed requests:        0
Total transferred:      110500 bytes
HTML transferred:       21000 bytes
Requests per second:    65.89 [#/sec] (mean)
Time per request:       75.881 [ms] (mean)
Time per request:       15.176 [ms] (mean, across all concurrent requests)
Transfer rate:          14.22 [Kbytes/sec] received

4.opcache enabled, cache_list configuration

Concurrency Level:      5
Time taken for tests:   1.312 seconds
Complete requests:      500
Failed requests:        0
Total transferred:      110500 bytes
HTML transferred:       21000 bytes
Requests per second:    381.01 [#/sec] (mean)
Time per request:       13.123 [ms] (mean)
Time per request:       2.625 [ms] (mean, across all concurrent requests)
Transfer rate:          82.23 [Kbytes/sec] received

Test results

1. Enable opcache, very significant performance improvement.

7.665 -> 1.406

7.588 -> 1.312

2. Enable phar.cache_list: there is a little improvement on performance.

7.665 -> 7.588

1.406 -> 1.312

To encrypt this: Let's Encrypt version of the page to get SSL certificates Website: https://letsencrypt.osfipin.com/ .

Therefore, the most common practice is to use opcache.

Guess you like

Origin www.cnblogs.com/osfipin/p/11926495.html
Recommended