In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article shows you what tips to achieve the highest performance of php7, the content is concise and easy to understand, can definitely brighten your eyes, through the detailed introduction of this article, I hope you can get something.
1. Opcache
Remember to enable Zend Opcache, because PHP7 is faster than PHP-5.6 with Opcache even if it doesn't enable Opcache, so it happened during the previous testing period that someone didn't enable Opcache. It's easy to enable Opcache by adding the following to the php.ini configuration file:
Zend_extension=opcache.soopcache.enable=1opcache.enable_cli=1 "
two。 Use the new compiler
Using a newer compiler, more than GCC 4.8 is recommended, because only PHP above GCC 4.8 will enable Global Register for opline and execute_data support, which will bring about a 5% performance improvement (measured from Wordpres's QPS point of view)
In fact, previous versions of GCC 4.8 also support it, but we found that it supports Bug, so it must be a version of 4.8 or above to enable this feature.
3. HugePage
First open HugePages in the system, and then turn on Opcache's huge_code_pages.
Take my CentOS 7.0as an example, through:
$sudo sysctl vm.nr_hugepages=512
Allocate 512 reserved large pages of memory:
$cat / proc/meminfo | grep HugeAnonHugePages: 106496 kBHugePages_Total: 512HugePages_Free: 504HugePages_Rsvd: 27HugePages_Surp: 0Hugepagesize: 2048 kB
Then add the following to php.ini:
Opcache.huge_code_pages=1
In this way, PHP will save its own text segments, as well as the huge in memory allocation, with large memory pages, reducing TLB miss and improving performance.
4. Opcache file cache
Turn on Opcache File Cache (experimental). By turning on this, we can let Opcache cache the opcode cache to external files. For some scripts, there will be a significant performance improvement.
Add the following to php.ini:
Opcache.file_cache=/tmp
In this way, PHP will Cache some Opcode binary export files under the / tmp directory, which can exist across the PHP life cycle.
5. PGO
My previous article: make your PHP7 faster (GCC PGO) also introduced that if your PHP is specifically for a project, such as only for your Wordpress, or drupal, or whatever, then you can try to use PGO to improve PHP, specifically for your project performance.
Specifically, taking wordpress 4.1as the optimized scenario.. First, when compiling PHP, first:
$make prof-gen
Then train PHP with your project, for example, for Wordpress:
$sapi/cgi/php-cgi-T 100 / www/htdocs/yii2/index.php > / dev/null
That is, let php-cgi run the home page of wordpress 100 times to generate some profile information in the process.
Finally:
Make prof-clean$ make prof-use & & make install what are the tips for maximizing php7 performance? have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.