PHP7 Performance Optimization

Source: Internet
Author: User

Previously used PHP version are 6.5/6.6, this project development requires the use of PHP7, on-line probably looked under, found that PHP7 performance compared to the previous upgrade a lot, so use PHP7 I have no opinion, gladly accept.

Wenzhou today a customer to do activities, resulting in a sudden number of users, the original server is still in the beta stage, the server and PHP environment did not do the relevant performance optimization, and the server configuration is relatively low, resulting in the PHP-FPM process hangs dead state, once service all hung.

Good, nonsense not much to say, today the main record PHP7 related optimization, data is also from the online search for a long time, finishing the next, ready to optimize the night to see the effect.

1. Open Zend Opcache

Zend Opcache supports the php5.2.0+ version, but what exactly is Zend Opcache? Official presentation translation is a faster PHP execution through code caching and optimization. According to the official introduction: by storing the compiled code in share memory to improve execution speed (PS: can be configured to determine his storage time), eliminating the time to read from disk and compile (PS: This is actually the most expensive part of the time), in addition, There are also some code optimization modes to improve execution speed (PS: The official does not give this optimization principle). Well above is the official introduction, I try to read a few more times, understand understanding.

Here's how to start the php.ini file by adding:

Zend_extension=opcache.so

Opcache.enable=1

Opcache.enable_cli=1


2, hugepage large page memory management mode

For more information about Hugepage, refer to: http://blog.csdn.net/leshami/article/details/8777639

First turn on the hugepage in the system, and then turn on the Opcache huge_code_pages:

Sysctl vm.nr_hugepages=512 # #分配512个预留的大页内存

Cat/proc/meminfo | grep Huge

Then add in the php.ini:

Opcache.huge_code_pages=1


3. Opcache File Cache

Open the Opcache file cache, which allows opcache to cache the opcode cache in an external file, with a noticeable performance boost for some scripts. Add in php.ini:

Opcache.file_cache=/tmp


4. PGO

This piece is not very understanding, back again update ...

This article is from the "Opsworld" blog, make sure to keep this source http://cuimengah.blog.51cto.com/12607637/1980385

PHP7 Performance Optimization

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.