In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Today Xiaobian to share with you how to use yum way to install PHP7 and performance testing related knowledge points, detailed content, clear logic, I believe most people still know too much about this knowledge, so share this article for everyone to refer to, I hope you read this article after harvest, let's learn about it together.
PHP7 and HHVM
For ordinary PHP websites, mainly IO-intensive, the bottleneck is above MySQL data, which does not reflect the disadvantages of PHP performance. But in intensive computing than C, C++, Java static compilation language dozens of times or even hundreds of times worse. If you use a more complex framework, such as symfony, in PHP development, the performance of the program will decrease significantly. In fact, PHP was not originally designed to solve computationally intensive application scenarios. We can roughly understand that PHP sacrifices execution efficiency in order to improve development efficiency.
However, PHP is more popular, such as Sina Weibo, Facebook, most of the programs are written in PHP, that is, in this large-scale application, PHP performance is low. Much of Facebook's early code was developed using PHP, but as the business grew rapidly, PHP execution efficiency became an increasingly obvious problem. In order to optimize execution efficiency, Facebook started using HipHop in 2008, a PHP execution engine that was originally designed to convert a large amount of PHP code from Fackbook to C++ to improve performance and save resources. PHP code that uses HipHop has several times the performance boost. Later, Facebook will HipHop platform open source, gradually developed into the current HHVM. HHVM is used to replace PHP's own Zend Engine. It is said that the performance has increased by 70%. Of course, PHP officials also know PHP's biggest shortcomings, so they launched the PHP7 project, mainly to refactor the Zend Engine engine.
The most notable change in PHP 7 is a huge performance boost, approaching Facebook's PHP execution engine HHVM. In WordPress benchmark performance tests, it was two to three times faster than version 5.6, significantly reducing memory footprint. PHP 7 also has some language changes, such as adding return type declarations, adding some new reserved keywords, etc. In terms of security, PHP security mode has been removed and magic quotes have been added. Not only that, the new version also supports 64-bit and includes the latest version of the Zend engine. In fact, PHP7's performance in real scenarios is indeed comparable to HHVM, and in some scenarios even exceeds HHVM. However, HHVM's operation and maintenance is complex, and it is a multithreaded model, which means that if a thread causes a crash, the entire service will hang up, and it will not automatically restart. In addition, it uses JIT, which means that after restart to warm up, there is no preheating case, the performance is worse. And the multithreaded model is difficult to debug, which is very inappropriate for Web services that pursue stability.
YUM Install PHP7
To use the latest version of PHP, you need to use the REMI source, Remi repository is a Linux source containing the latest version of PHP and MySQL packages, maintained by Remi. After having this source, use YUM to install or update PHP, MySQL newer versions.
Install the latest Remi source auto-install files
# CentOS 6 / RHEL 6yum install http://rpms.famillecollet.com/enterprise/remi-release-6.rpm# CentOS 7 / RHEL 7yum install http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
Install PHP related components, provided below is a standard installation that can be used in a production environment.
$ yum --enablerepo=remi,remi-php70 installphp \php-cgi \php-cli \php-fpm \php-common \php-devel \php-mysqlnd \php-mysql \php-sqlite3 \php-mbstring \php-msgpack \php-mcrypt \php-bcmath \php-gd \php-xml \php-ldap \php-xmlrpc \php-opcache \php-curl \php-json \php-odbc \php-pdo \php-bz2 \php-xml \php-ftp \php-imap \php-snmp \php-redis \php-memcached
View PHP version
$ php -vPHP 7.0.9 (cli) (built: Jul 20 2016 18:08:08) ( NTS )
start PHP-FPM
$ service php-fpm start
PHP 7.0 is installed. If you need to use PHP extensions, such as redis, memcached, etc., you only need to use YUM installation, as follows:
$ yum --enablerepo=remi,remi-php70 install php-redis php-memcached
If you can't find the extension you need in either REMI or EPEL sources, you'll need to manually compile and install it, which is easy.
Also check PHP module information using php -m command.
$ php -m | grep redisredis
Install a set of LNMP reference: LNMP installation package deployment actual combat or refer to PHP7.0 version of LNMPZabbix 3.0 installation use detailed explanation
PHP7 Performance Test
Environment: 4-core CPU, 4G memory, operating system Centos 6.5.
First of all, a little bit of GCC compiler advice, according to bird brother's suggestion, use a new compiler, recommend GCC 4.8 or above, because only GCC 4.8 or above PHP will open Global Register for opline and execute_data support, this will bring about 5% performance improvement.
Write a program (simple test method available online):
The first paragraph generates an array of 600,000 elements and determines whether the key exists by looking up the key.
$a = array();for($i=0;$i$i++){ $a[$i] = $i;}foreach($a as $i){array_key_exists($i, $a);}
PHP version 5.3.17.
[root@localhost test]# time php search_by_key.phpreal 0m0.389suser 0m0.337ssys 0m0.051s[root@localhost test]# time php search_by_key.phpreal 0m0.378suser 0m0.308ssys 0m0.062s[root@localhost test]# time php search_by_key.phpreal 0m0.378suser 0m0.317ssys 0m0.061s
PHP 7.0 is the next version.
[root@localhost php7]# time php7 search_by_key.phpreal 0m0.082suser 0m0.066ssys 0m0.014s[root@localhost php7]# time php7 search_by_key.phpreal 0m0.080suser 0m0.058ssys 0m0.021s[root@localhost php7]# time php7 search_by_key.phpreal 0m0.080suser 0m0.053ssys 0m0.026s`
Response time at PHP7 is 1/4 of the original.
This is still the way above, but due to the slower speed, it becomes an array of 60000 elements, looking for values.
$a = array();for($i=0;$i$i++){ $a[$i] = $i;}foreach($a as $i){array_key_exists($i, $a);}[root@localhost test]# time php search_by_val.phpreal 0m24.296suser 0m24.184ssys 0m0.025s[root@localhost test]# time php search_by_val.phpreal 0m25.523suser 0m25.317ssys 0m0.026s[root@localhost test]# time php search_by_val.phpreal 0m26.026suser 0m25.478ssys 0m0.092s
The waiting time always felt very long. Three tests took more than 75 seconds. PHP 7 is here.
[root@localhost php7]# time php7 search_by_val.phpreal 0m3.362suser 0m3.323ssys 0m0.007s[root@localhost php7]# time php7 search_by_val.phpreal 0m3.266suser 0m3.251ssys 0m0.004s[root@localhost php7]# time php7 search_by_val.phpreal 0m3.290suser 0m3.275ssys 0m0.006s
Yes or no! The speed has increased nearly seven times.
The above is "How to install PHP7 and test its performance with yum" all the contents of this article, thank you for reading! I believe everyone has a great harvest after reading this article. Xiaobian will update different knowledge for everyone every day. If you want to learn more knowledge, please pay attention to 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.