How is the performance of PHP 7.3? The following is an in-depth test of the latest version and features of PHP: PHP 7.3 is more than 3 times faster than PHP 5!
As the last version of PHP5 and currently the most widely used PHP version, PHP 5.6 started in 2014 AD (not 1804, hehe), and its first beta version, PHP 5.6 alpha 1, was released in 2014 Released in January. The first large-scale performance-improved version PHPNG (PHP next generation, next generation PHP) was randomly generated by Chinese people (Niao Ge, Hui Xinchen) and participated in the main research and development. In 2015, the PHP 7 version was produced based on PHPNG. PHP7 brings revolutionary performance improvements, running at twice the speed of 5.6 and other improvements, such as 64-bit support, type declarations, runtime optimization, etc. Since 2015, officials have been recommending that everyone upgrade to php7 as soon as possible, although expansion support was still very problematic at that time.
According to the latest W3techs statistics, PHP 7 currently accounts for more than 16.6% of PHP's share. Overall PHP still holds the majority share of server-side web development languages at around 83%.
#Performance test: PHP 7.3 is 25% faster than PHP 7.0
There are many performance test comparisons that reveal that PHP 7 is at least 2 times faster than PHP 5.6. The following is a performance comparison chart of major PHP frameworks:
##The latest Phoronix benchmark results are below It shows the performance comparison of PHP 7 since PHP7 was released. The performance improvement of the latest version of PHP 7.3 Alpha is quite objective compared to the initial version of PHP 7. According to the latest data PHP 7.3 is 3 times faster than PHP 5.6! 25% faster than PHP 7.0. Not to mention anything else, this performance comparison chart can bring a little bit of coolness to the scorching summer. And this can also be directly reflected in the cost. For example, after upgrading to PHP7, Badoo can save about 1 million US dollars per year.
As of now, basically the vast majority of PHP All can perfectly support PHP7.0. But maybe you happen to have some scripts and programs left over from history, so it’s easy to handle. The community already has many tools for compatibility checking and even direct code translation. Here are a few recommended tools:
php7cc: A very good tool, but it is no longer updated. (github address: /sstalle/php7cc)
##php7mar: PHP 7 migration assistant, bug Highly recommended tool. (github address: /Alexia/php7mar)
##Usage:
phan: Static analyzer for PHP scripts. Can be used as a syntax checker for PHP 7. (github address: /phan/phan)
phpstan - PHP static analysis and compatibility checking tool. (github address: /phpstan/phpstan)
PHP 7 performance setting points
1. Opcache
First, make sure it is enabled OpCache. This can be done through the main configuration file php.ini or its unique configuration file opcache.ini file (for example /etc/php/7.2/fpm/conf.d/10-opcache.ini). to set it up.
opcache.enable=1
opcache.enable_cli=1
You can use phpinfo() to check, or you can use the terminal command
php -v or php -i | grep opcache.enable
After confirming that PHP OpCache has been enabled, many ln(a)mp packages have an opCache monitoring script that can monitor their performance in real time, as shown below
2. Set an appropriate realpath_cache_size
You can improve the performance of your server by setting an appropriate realpath_cache_size value Concurrency:
realpath_cache_size = 256k
realpath_cache_ttl = 300