PHP7.2 Update github.com/php/php-src… I don’t seem to see any changes in overall performance from the official documentation.

PHP7.2 is also optimized in Opcache compared to PHP7.1.

Server Configuration

2-core Intel(R) Xeon(R) CPU E5-2640 0 @ 2.50GHz Memory 4 gb system Centos 6.2 GCC 4.4.7Copy the code

The installation

# http://hk1.php.net/get/php-7.1.10.tar.gz/from/this/mirror $. / configure -- prefix = / data/local/php71 --with-config-file-path=/data/local/php71/etc --enable-fpm --with-fpm-user=www --with-fpm-group=www --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir --with-freetype-dir=/usr/local/freetype --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --enable-intl --enable-pcntl --with-mcrypt --enable-ftp --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --with-gettext --disable-fileinfo --enable-opcache --with-xslCopy the code
# https://downloads.php.net/~remi/php-7.2.0RC3.tar.gz $. / configure -- prefix = / data/local/php72 --with-config-file-path=/data/local/php72/etc --enable-fpm --with-fpm-user=www --with-fpm-group=www --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir --with-freetype-dir=/usr/local/freetype --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --enable-intl --enable-pcntl --enable-ftp --with-gd --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --with-gettext --disable-fileinfo --enable-opcache --with-xslCopy the code
$/ data/local/PHP 7.1.10 php71 / bin/PHP - v (cli) (built: Oct 8 2017 16:08:01) (NTS) Copyright (C) 1997-2017 The PHP Group Zend Engine V3.1.0, Copyright (c) 1998-2017 the Zend Technologies, $/ data/local/PHP php72 / bin/PHP - v 7.2.0 RC3 (cli) (built: Oct 8 2017 18:11:35) (NTS) Copyright (c) 1997-2017 The PHP Group Zend Engine V3.2.0-dev, Copyright (c) 1998-2017 Zend TechnologiesCopy the code

The php.ini configuration

Only for test, use non-production environments, an excerpt from www.laruence.com/2016/12/18/…

engine = On
short_open_tag = Off
realpath_cache_size = 2M
max_execution_time = 86400
memory_limit = 1024M
error_reporting = 0
display_errors = 0
display_startup_errors = 0
log_errors = 0
default_charset = "UTF-8"
 
[opcache]
zend_extension=opcache.so
opcache.enable=1
opcache.enable_cli=1
opcache.optimization_level=-1
opcache.fast_shutdown=1
opcache.validate_timestamps=1
opcache.revalidate_freq=60
opcache.use_cwd=1
opcache.max_accelerated_files=100000
opcache.max_wasted_percentage=5
opcache.memory_consumption=128
opcache.consistency_checks=0
opcache.huge_code_pages=1Copy the code

Pure CPU benchmarking

Based on theZend/bench.phpScript tests for

Not open opcache

$ for i in `seq 1 10`; Do/data/local/php71 / data/bin/PHP/soft/PHP - 7.2.0 RC3 / Zend/bench. PHP | grep 'Total' | awk '{print $0}'. Done Total 1.381 Total 1.416 Total 1.374 Total 1.366 Total 1.430 Total 1.394 Total 1.394 Total 1.369 Total 1.377 Total For I in 'seq 1 10'; Do/data/local/php72 / data/bin/PHP/soft/PHP - 7.2.0 RC3 / Zend/bench. PHP | grep 'Total' | awk '{print $0}'. Done Total 1.448 Total 1.444 Total 1.445 Total 1.458 Total 1.440 Total 1.447 Total 1.486 Total 1.433 Total 1.449 Total # Take the average value 1.4514Copy the code

After OpCache is enabled

$ for i in `seq 1 10`; Do/data/local/php71 / data/bin/PHP/soft/PHP - 7.2.0 RC3 / Zend/bench. PHP | grep 'Total' | awk '{print $0}'. Done Total 0.794 Total 0.797 Total 0.798 Total 0.806 Total 0.808 Total 0.793 Total 0.814 Total 0.846 Total 0.859 Total $for I in 'seq 1 10'; Do/data/local/php72 / data/bin/PHP/soft/PHP - 7.2.0 RC3 / Zend/bench. PHP | grep 'Total' | awk '{print $0}'. Done Total 0.779 Total 0.774 Total 0.765 Total 0.772 Total 0.764 Total 0.769 Total 0.779 Total 0.839 Total 0.784 Total The average value of 0.842 # is 0.7867Copy the code

In this test, without opcache enabled, THE performance of PHP7.2 decreased somewhat. After opCache was enabled, the performance caught up and improved slightly compared to PHP7.1. All the more reason to enable OpCache.

Based on theZend/micro_bench.phpScript tests for

Not open opcache

$ for i in `seq 1 10`; Do/data/local/php71 / data/bin/PHP/soft/PHP - 7.2.0 RC3 / Zend/micro_bench. PHP | grep 'Total' | awk '{print $0}'. Done Total 5.588 Total 5.689 Total 5.652 Total 5.702 Total 5.668 Total 5.641 Total 5.622 Total 5.580 Total 5.635 Total For I in 'seq 1 10'; Do/data/local/php72 / data/bin/PHP/soft/PHP - 7.2.0 RC3 / Zend/micro_bench. PHP | grep 'Total' | awk '{print $0}'. Done Total 5.924 Total 5.597 Total 5.553 Total 5.579 Total 5.591 Total 5.523 Total 5.518 Total 5.503 Total 5.494 Total 5.558 # Take the average value 5.584Copy the code

Open opcache

$ for i in `seq 1 10`; Do/data/local/php71 / data/bin/PHP/soft/PHP - 7.2.0 RC3 / Zend/micro_bench. PHP | grep 'Total' | awk '{print $0}'. Done Total 4.369 Total 4.379 Total 4.352 Total 4.370 Total 4.375 Total 4.397 Total 4.311 Total 4.361 Total 4.313 Total For I in 'seq 1 10'; Do/data/local/php72 / data/bin/PHP/soft/PHP - 7.2.0 RC3 / Zend/micro_bench. PHP | grep 'Total' | awk '{print $0}'. Done Total 3.711 Total 3.711 Total 3.712 Total 3.734 Total 3.700 Total 3.712 Total 3.705 Total 3.769 Total 3.785 Total # Take the average value 3.7234Copy the code

In this test, when opcache is not enabled, the performance of PHP7.2 is slightly better than that of PHP7.1. After Opcache is enabled, the performance of PHP7.2 is much better than that of PHP7.1.

Graphs of

summary bench.php bench.php + opcache micro_bench.php micro_bench.php + opcache
PHP7.1 1.3859 0.8133 5.6365 4.3600
PHP7.2 1.4514 0.7867 5.5840 3.7234

Software application testing

Configuration instructions

2-core Intel(R) Xeon(R) CPU E5-2640 0 @ 2.50GHz Memory 4 gb system Centos 6.2 Nginx 1.10.1 mysql 5.5.28 wordpress 4.8.1Copy the code

Considering that other services such as my blog are already running on this server, the number of phP-fPM child processes is only 15, compared under the condition of the same configuration file.

# php-fpm simple configuration, Pid = /data/local/php7{x}/var/run/ php-ftp. pid error_log = /data/log/php7{x} -ftp. log log_level = notice [WWW] listen = / TMP /php7{x}-cgi.sock listen.backlog = -1 listen.allowed_clients = 127.0.0.1 listen.owner = WWW listen.group = www listen.mode = 0666 user = www group = www pm = static pm.max_children = 15Copy the code

WordPress pressure measurement

Not open opcache

# php7.1 Concurrency Level: 10 Time taken for Tests: 8.696 seconds Complete requests: 100 Failed requests: 0 Write errors: 0 Total transferred: 5215300 bytes HTML transferred: 5189300 bytes Requests per second: 11.50 [#/ SEC] (mean) Time per request: 869.637 [ms] (mean) Time per request: 86.964 [MS] (mean, across all concurrent requests) Transfer rate: 585.65 [Kbytes/ SEC] ReceivedCopy the code
# php7.2 Concurrency Level: 10 Time taken for Tests: 8.528 seconds Complete requests: 100 Failed requests: 0 Write errors: 0 Total transferred: 5215500 bytes HTML transferred: 5189300 bytes Requests per second: 11.73 [#/ SEC] (mean Time per request: 852.793 [ms] (mean Time per request: 852.793) 85.279 [ms] (mean, across all concurrent requests) Transfer rate: 597.24 [Kbytes/ SEC] ReceivedCopy the code

As you can see, the performance is very poor when opCache is not enabled. With 10 concurrent requests, the response time per request is already very long and there is no need to increase the number of concurrent requests.

After OpCache is enabled

summary 7.1 Requests per second 7.1 Time per request (ms) 7.2 Requests per second 7.2 Time per request (ms)
c10 n100 60.63 164.939 70.05 142.762
c20 n200 66.27 301.803 70.74 282.719
c30 n300 66.50 451.121 70.89 423.2
c40 n400 67.95 588.683 70.6 566.608

With OpCache enabled, performance is dramatically different than it would have been otherwise. In contrast, PHP7.2 on wordpress pressure test, THE QPS stable at 70+ relative php7.1 increased a lot.

The test results are related to configuration parameters and server configuration and are only used to compare THE performance of PHP7.1 and 7.2.

Other faster ways to make your PHP, please refer to the @ Laruence www.laruence.com/2015/12/04/…