PHP 7 Installation experience, upgrade PHP to be cautious

Source: Internet
Author: User
Tags hhvm vps drupal vps server



First, the performance of PHP 7 several key points



PHP 7 compared to the previous version of PHP can say that the performance has a qualitative leap, but the so-called "good Horse with good saddle, good car with sail", want to play PHP 7 performance advantages, but also need to prepare from the following aspects: (this part is quoted from PHP7 core developers, YAF, Yar, Yac and other Items laruence).






1. Remember to enable Zend Opcache, enabling Opcache is very simple, include in the php.ini configuration file:



zend_extension=opcache.soopcache.enable=1opcache.enable_cli=1"


2. Using the new compiler, it is recommended that GCC 4.8 or more, because only gcc 4.8 or more PHP 7 will turn on the global Register for Opline and execute_data support, this will bring about 5% performance improvement.






3. Open Hugepage facilitates PHP 7 faster, first in the system to open hugepages, and then turn on Opcache huge_code_pages, CentOS 6.5 as an example, through the command: $sudo sysctl vm.nr_ HUGEPAGES=512, allocate 512 reserved large pages of memory:



$ cat/proc/meminfo  | gr EP HugeANONHUGEPAGES:    106496kbhugepages_total:      512hugepages_free:       504HUGEPAGES_RSVD:        27hugepages_surp:        0HUGEPAGESIZE:       2048kb


Then add in php.ini: Opcache.huge_code_pages=1, so that PHP will be its own text segment, as well as memory allocation of huge are used in large memory pages to save, reduce TLB miss, thereby improving performance.



4. Open Opcache File Cache (experimental), by opening this, you can let opcache cache opcode cache to external files, for some scripts, there will be a significant performance improvement. The method is to add: Opcache.file_cache=/tmp in php.ini. This will allow PHP to cache some opcode binary export files in the/tmp directory, which can exist across the PHP life cycle.



5. PGO. If your PHP is dedicated to a project, such as just for your WordPress, or Drupal, or whatever, then you can try to improve PHP with PGO, specifically to improve performance for your project. Specifically, take WordPress 4.1 as the optimization scenario. First, when compiling PHP, first: $ make prof-gen.



6. Then use your project to train PHP, for example for wordpress:$ sapi/cgi/php-cgi-t 100/home/huixinchen/local/www/htdocs/wordpress/index.php >/ Dev/null, that is, let php-cgi run 100 times the homepage of WordPress, thus generating some profile information in the process. At last:



$ make prof-clean$ make prof-use && make install


7. The PHP7 you compile at this time is the most high-performance compiled version tailored for your project.






Second, PHP 7 installation and compilation



1, PHP 7 official website:


    • 1. Official website: http://php.net/
    • 2. Download: http://php.net/downloads.php


2, hands-on ability of friends, you can directly to the official download PHP 7, and then manually edit the installation. If you are accustomed to using the lnmp.org webmaster's LNMP One-click installation package, you can try to release the LNMP 1.3 beta, has increased the PHP7 support: the smooth migration of the site to LNMP or lamp to build a station environment method.



3, Oneinstack provides the LNMP installation package already has the PHP 71 key installs, when executes the script, may choose the PHP 7 installs, PHP 7 currently only has the official own Zend Opcache extension to install.






4, Oneinstack installation of PHP 7 installed successfully.






5, this is the PHP 7 information display.






6. This is the Opcache Control Panel of PHP 7 provided by Oneinstack.






Third, PHP 7 and the old version of PHP, HHVM performance Comparison



1, this is the foreign developer test PHP 7 and PHP 5.6 in WordPress, Drupal and other popular programs performance, the result is obviously PHP 7 performance improvement.






2, PHP 7 for WordPress and other programs, not only to improve the speed of a single execution, with WordPress running in PHP 7 the longer, performance improvement is more.






3, the above also said that PHP 7 for PHP performance improvement in some aspects has exceeded the HHVM, which is the foreign Zend.com official website given PHP 5.6, PHP 7, HHVM in different programs to perform efficiency comparison results.



4, in the professional open-source e-commerce system magento test PHP 5.6, PHP 7, HHVM execution efficiency, PHP 7 is PHP 5.6 running speed of twice times, and memory consumption is also lower than PHP 5.6 30%.






5, Drupal 8 on the test PHP 7 efficiency is the fastest, has exceeded the HHVM.






6, the WordPress test found that PHP 5.6 execution needs to occupy 100MB of memory, and PHP 7 only 25MB.






7, in different program execution speed, PHP 7 obviously has the lead, Ruby 2.1, Python 2.7.8, Perl 5.18.4 are less than PHP 7.






Iv. PHP 7 Performance Test Results report



1, empty Say no, PHP 7 running program performance in the end? Here the tribe with a brand-new WordPress test object, run on PHP 7 WordPress home Page load time test display 0.029 seconds, memory is 3.39MB.






2, this is the same WordPress page run PHP 5.6 on the page load time: 1.955 seconds, memory consumption of 3.92MB. From the data, PHP 7 has already won out PHP 5.6.






3, PHP 7 running WordPress Efficiency relative to the previous version did have a qualitative improvement, in order to fully understand the performance of PHP 7, here according to the Web server pressure Web performance test method, with Webbench simulation 10 seconds 200, 400 connections, the speed is 8000 pages /min.






4, at this time, VPS Server system load is 3.49.






5, to increase the number of analog connections to 1600, the speed remains at 8000 pages/min.






6, at this time, VPS Server system load is 17, it should be a little hard.






7. Increase the number of analog connections to 5,000, the speed is 4800 pages/min, the speed began to slow down.






8, at this time, VPS Server system load is 23, the server is overweight.






9, in order to test PHP 7 in this VPS host capacity limit, Webbench analog 10,000 connection number in 20 seconds continuously access the server.






10, at this time, VPS Server system load nearly 90, should be reached the limit, but the server still does not crash.






11, Next, let us take a look at the same configuration of the VPS host running WordPress stress test results, the first is to use Webbench to simulate 10 seconds within 200, 400 connections, the speed is 3600 pages/min, compared to the above PHP 7 test speed is half slow.






12, this is the PHP 5.6 test 200, 400 connections of the system load, has reached 10, significantly more than in the PHP 7 environment test 3.49.






13, in the PHP 5.6 test to increase the number of analog connections to 1000, 2000, when the speed has been reduced to 1600 pages/min, the number of successful connections also decreased to about 500, much lower than in the PHP 7 test 2700.






14. At this time, the system load has reached 17.






15, in PHP 5.6 with Webbench Test connection number is 10000, in 20 seconds to continuously access the server. At this point, the test is stuck and there is no result.






16, here VPS Server System load has reached more than 1000, the server has crashed.






17, PHP 5.6 Under the WordPress site has been down.






Five, PHP 7 compatibility issues



1, the current domestic discuz and so on also do not support PHP 7,php extension is only the official Opcache can use, other such as Eaccelerator, XCache, memcached, etc., you can always focus on the Extended support list: https:// Github.com/gophp7/gophp7-ext/wiki/extensions-catalog. PHP's Memcache extension already has: HTTPS://GITHUB.COM/PHP-MEMCACHED-DEV/PHP-MEMCACHED/TREE/PHP7 and https://github.com/ Websupport-sk/pecl-memcache. Thanks for the reminder of happy home bloggers.






2, after testing, PHP 7 run WordPress without any problems.






3, install the wordpress plugin on PHP 7 is not a problem.






4, PHP 7 There are some functions, operators and other possible incompatibility problems, but 99% of the program may not be used.



Vi. Summary of PHP 7 installation and usage experience



1, the use of PHP 7 after a surprise is that, indeed, as foreign developers testing, PHP 7 performance is basically flat with HHVM, because HHVM with the real-time (Just in) compiler to compile PHP code to machine instructions, so a lot of PHP programs run in HHVM needs to be improved.



2, PHP 7 with HHVM ultra-high performance, but also with the advantages of PHP backwards compatibility, I believe in the near future PHP 7 will be more and more people's recognition and acceptance. While the current support for PHP 7 cache, acceleration and other extensions is not much, but it is only a matter of time, more and more developers will be added to the development of PHP 7 in the ranks.



From: http://www.phpxs.com/j/php7/1001234



PHP 7 Installation experience, upgrade PHP to be cautious


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.