当前位置:网站首页>How to install php7 and perform performance test using yum
How to install php7 and perform performance test using yum
2022-07-01 12:13:00 【Yisu cloud】
How to use yum Mode of installation PHP7 And performance test
Today, I'd like to share with you how to use yum Mode of installation PHP7 And the relevant knowledge points of performance testing , Detailed content , Clear logic , I believe most people still know too much about this knowledge , So share this article for your reference , I hope you will gain something after reading this article , Now let's take a look .

PHP7 And HHVM
For ordinary PHP Website , Mainly IO intensive , The bottleneck is MySQL On top of the data , Don't show PHP Performance disadvantages . But in terms of Intensive Computing C、C++、Java This statically compiled language is dozens or even hundreds of times worse . If in PHP A more complex framework is used in the development , Such as symfony, Program performance will decline significantly . in fact ,PHP The original design of the language , It is not used to solve computing intensive application scenarios . We can roughly understand it as ,PHP In order to improve development efficiency , At the expense of execution efficiency .
but PHP More popular , Such as Sina Weibo 、Facebook Most programs of this large website use PHP Written , That is, in this large-scale application ,PHP Low performance shows up .Facebook Many early codes used PHP To develop , however , With the rapid development of business ,PHP Execution efficiency is becoming more and more obvious . To optimize execution efficiency ,Facebook stay 2008 It's been in use since HipHop, This is a kind of PHP Execution engine , Initially, it was to make Fackbook A large number of PHP The code to C++, To improve performance and save resources . Use HipHop Of PHP The performance of the code has been improved several times . later ,Facebook take HipHop Open source platform , Gradually develop into the present HHVM.HHVM To replace PHP The engine used by itself Zend Engine. It is said that the performance has been improved 70%. Of course PHP Officials also know PHP The biggest short board , So it follows PHP7 project , Mainly refactored Zend Engine engine .
PHP7 The most significant change is the great improvement of performance , Is close to Facebook Developed PHP Execution engine HHVM. stay WordPress Benchmark performance test , Velocity ratio 5.6 The version should be fast 2~3 times , Greatly reduce memory consumption .PHP7 There are also some changes in language , For example, add a return type declaration 、 Some new reserved keywords are added . On the safety side , In addition to the PHP safe mode , Add magic quotes, etc . More Than This , The new version also supports 64 position , And include the latest version Zend engine . Actually PHP7 The performance of in real scenes has indeed been compared with HHVM Quite a , In some scenes, it even exceeds HHVM. but HHVM The operation and maintenance of is complex , It's a multithreading model , This means that if a thread causes crash 了 , Then the whole service will hang up , And it will not restart automatically . In addition, it uses JIT, That means , Warm up after restart , Without preheating , Poor performance . And the debugging of multithreaded model is difficult , This is for the pursuit of stability Web For service , It's very inappropriate .
YUM install PHP7
Want to use the latest version PHP, You need to use it REMI Source ,Remi repository It contains the latest version PHP and MySQL Bag Linux Source , from Remi Provide maintenance . With this source , Use YUM Install or update PHP、MySQL Newer version .
Install the latest Remi Source automatic installation file
# 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 , The following is a standard installation that can be used in the production environment .
$ yum --enablerepo=remi,remi-php70 install php \ 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
see PHP edition
$ php -v PHP 7.0.9 (cli) (built: Jul 20 2016 18:08:08) ( NTS )
start-up PHP-FPM
$ service php-fpm start
Come here ,PHP7.0 The installation is complete . If you need to use PHP Extend the functionality , Such as redis、memcached etc. , Just use YUM Can be installed , as follows :
$ yum --enablerepo=remi,remi-php70 install php-redis php-memcached
If in REMI or EPEL The extension module you need cannot be found in the source , Then you need to compile and install manually , It's also very simple. .
Also check out PHP Module information usage php -m command .
$ php -m | grep redis redis
Install a set of LNMP Reference resources :LNMP Installation package deployment practice or reference PHP7.0 Version of LNMPZabbix 3.0 Installation and use details
PHP7 Performance testing
Environmental Science :4 nucleus CPU, Memory 4G, operating system Centos 6.5.
First of all, let's say GCC Compiler recommendations , According to brother bird's suggestion , Use a new compiler , recommend GCC 4.8 above , Because only GCC 4.8 above PHP Will open Global Register for opline and execute_data Support , This will bring 5% Left right performance improvement .
Write a program ( Simple testing methods provided online ):
The first paragraph , Generate a 60 An array of 10000 elements , By looking for key The way , To make sure key Whether there is .
$a = array();for($i=0;$i$i++){
$a[$i] = $i;
}
foreach($a as $i)
{
array_key_exists($i, $a);
}First of all PHP 5.3.17 edition .
[[email protected] test]# time php search_by_key.phpreal 0m0.389s user 0m0.337s sys 0m0.051s [[email protected] test]# time php search_by_key.phpreal 0m0.378s user 0m0.308s sys 0m0.062s [[email protected] test]# time php search_by_key.phpreal 0m0.378s user 0m0.317s sys 0m0.061s
The second is PHP 7.0 edition .
[[email protected] php7]# time php7 search_by_key.phpreal 0m0.082s user 0m0.066s sys 0m0.014s [[email protected] php7]# time php7 search_by_key.phpreal 0m0.080s user 0m0.058s sys 0m0.021s [[email protected] php7]# time php7 search_by_key.phpreal 0m0.080s user 0m0.053s sys 0m0.026s`
The response time is PHP7 The next run becomes the original 1/4.
Or the way above , But because the speed is slow , So it becomes a 60000 Array of elements , Find value .
$a = array();for($i=0;$i$i++){
$a[$i] = $i;
}
foreach($a as $i)
{
array_key_exists($i, $a);
}
[[email protected] test]# time php search_by_val.phpreal 0m24.296s
user 0m24.184s
sys 0m0.025s
[[email protected] test]# time php search_by_val.phpreal 0m25.523s
user 0m25.317s
sys 0m0.026s
[[email protected] test]# time php search_by_val.phpreal 0m26.026s
user 0m25.478s
sys 0m0.092sWaiting time , Always feel very long , Three tests , It's gone 75 A second more . below ,PHP 7 Debut .
[[email protected] php7]# time php7 search_by_val.phpreal 0m3.362s user 0m3.323s sys 0m0.007s [[email protected] php7]# time php7 search_by_val.phpreal 0m3.266s user 0m3.251s sys 0m0.004s [[email protected] php7]# time php7 search_by_val.phpreal 0m3.290s user 0m3.275s sys 0m0.006s
Is there any ! The speed increased by nearly 7 times .
That's all “ How to use yum Mode of installation PHP7 And performance test ” All the content of this article , Thank you for reading ! I believe you will gain a lot after reading this article , Xiaobian will update different knowledge for you every day , If you want to learn more , Please pay attention to the Yisu cloud industry information channel .
边栏推荐
- GPS 数据中的精度因子(DOP)与协方差之间的关系 (参考链接)
- 栈的应用——括号匹配问题
- C#依赖注入(直白明了)讲解 一看就会系列
- Leetcode (Sword finger offer) - 58 - ii Rotate string left
- 我在中山,到哪里开户比较好?实际上网上开户安全么?
- Chen Gong: Micro service, is it still so pure?
- Onenet Internet of things platform - the console sends commands to mqtt product devices
- Binary stack (I) - principle and C implementation
- 【datawhale202206】pyTorch推荐系统:精排模型 DeepFM&DIN
- How does Nike dominate the list all the year round? Here comes the answer to the latest financial report
猜你喜欢
![[Yunju entrepreneurial foundation notes] Chapter 7 Entrepreneurial Resource test 2](/img/2b/f42ac6745eb126254af62ad5217f70.jpg)
[Yunju entrepreneurial foundation notes] Chapter 7 Entrepreneurial Resource test 2

本科毕业四年:工作,辞职,结婚,买房

队列操作---

比特熊直播间一周年,英雄集结令!邀你来合影!

Huawei HMS core joins hands with hypergraph to inject new momentum into 3D GIS

Interpretation of R & D effectiveness measurement framework
![[Yunju entrepreneurial foundation notes] Chapter 7 Entrepreneurial Resource test 7](/img/41/e3ecbd49e4bfeab6c6e7d8733fe33a.jpg)
[Yunju entrepreneurial foundation notes] Chapter 7 Entrepreneurial Resource test 7

MQ-防止消息丢失及重复消费

Typora realizes automatic uploading of picture pasting

Self organization is the two-way rush of managers and members
随机推荐
[Yunju entrepreneurial foundation notes] Chapter VII Entrepreneurial Resource test 1
Istio、eBPF 和 RSocket Broker:深入研究服务网格
Understanding of MVVM and MVC
指纹浏览器工作原理、使用场景以及重要性简单讲解
Machine learning - Data Science Library Day 3 - Notes
队列操作---
比特熊直播间一周年,英雄集结令!邀你来合影!
Emotion analysis based on IMDB comment data set
Blue Bridge Cup multi interface switching processing (enumeration plus state machine method)
C summary of knowledge points 3
[classic example] classic list questions @ list
One year anniversary of bitbear live studio, hero rally order! I invite you to take a group photo!
Abbirb120 industrial robot mechanical zero position
How to understand the developed query statements
usb peripheral 驱动 - cable connect/disconnect
Self organization is the two-way rush of managers and members
基于IMDB评论数据集的情感分析
Typora adds watermarks to automatically uploaded pictures
LeetCode 454. 四数相加 II
二叉堆(一) - 原理与C实现