In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Xiaosheng blog: http://xsboke.blog.51cto.com
-Thank you for your reference. If you have any questions, you are welcome to communicate.
I. Lamp work flow
1. Client requests web server, and the request page is php dynamic page.
2. Web server connects to php through cgi, fastcgi or apache modules
3. The php-fpm component of php server handles requests and parses php language through php parser.
4. Then php server fetches the data through the mysql protocol and returns it to web server
II. How Web server connects to php
1. Apache
There are three ways of Apache: CGI mode, fastCGI mode, and apache module.
2. Nginx
There are two ways of Nginx: FastCGI and proxy-pass
III. The working mechanism of FastCGI
The performance of fastCGI is better than that of CGI, so the production environment is generally the same as fastCGI mode.
There are two ways to request by client: dynamic request and static request
The static request is returned by the apache in direct response
Dynamic request needs to call phpserver through fastcgi protocol and return to apache. Apache returns the result after interpretation. If this process involves operation on data, php will also call mysql server through mysql protocol.
IV. Stress testing tools
1. Common stress testing tools
Ab 、 http_load 、 webbench 、 siege
2. Ab (stress testing tool included with apache)
The ab command creates multiple concurrent access threads to simulate multiple visitors accessing a URL address at the same time.
Its testing goal is based on URL, so it can be used to test not only the load pressure of apache, but also the pressure of other Web servers such as nginx, lighthttp, tomcat, IIS and so on.
Considerations for the use of Ab. By default, Linux can only open 1024 files at the same time, so a maximum of 1024 requests can be processed at the same time. This parameter is set by the variable ulimit. Ulimit-n can view the number of files currently allowed to open at the same time, or you can set the value directly.
5. Php accelerator xcache
1. Caching principle
When the php server interpreter parses a php page, it caches the parsed content in the cache file, when the same php
When a page is requested multiple times, it is not necessary to parse it every time and then respond to apache
Case: lamp+xcache
1. Case environment
two。 Build lamp platform
The installation of Apache and mysql is no longer described here, just start with the installation of php
Install the php dependency package first
Install libmcrypt
Compile and install php
-- prefix=/usr/local/php5.6: specify the installation directory
-- with-mysql=mysqlnd / / supports mysql
-- with-pdo-mysql=mysqlnd// supports pdo module
-- with-mysqli=mysqlnd// supports mysqli module
These three parameters are important parameters for lamp separation.
-- with-openssl// supports openssl module
-- enable-fpm// supports fpm mode
-- enable-sockets// enables socket support
-- enable-sysvshm// enables system shared memory support
Enable-mbstring// multi-byte strings, like our Chinese is multi-byte strings
-- with-freetype-dir// supports freetype, freetype-devel, font-related, font parsing tools
-- with-jpeg-dir
-- with-png-dir
Note: the function of the above two options: deal with jpeg, png pictures, php can dynamically generate jpeg pictures
-- with-zlib// is a compression library used to compress transmission over the Internet.
-- with-libxml-dir=/usr// this libxml is used to parse xml, specified under / usr
-- enable-xml / / support xml
-- with-mhash// supports mhash
-- with-mcrypt=/usr/local/libmcrypt / / libmcrypt-devel specified by this package
-- with-config-file-path=/etc// specifies the path where the configuration file is stored
-- with-config-file-scan-dir=/etc/php.d / / profile scan path
-- with-bz2 / / supports BZip2
Copy profile
Optimize the script path of php-fpm program
Copy the php-fpm configuration file
Configure the php-fpm file
Start the php-fpm service and open the 9000tcp port
Create a new virtual host directory on php server to store php web page files (and create two test pages)
Authorize an account on mysql server to test the connection and open the 3306tcp port
Configure apache connection php server in apache server
1)
2)
3)
4)
5)
6)
7)
3. Test the lamp platform
First test whether php can parse
Test whether you can connect to the mysql
4. Building xcache Accelerator on php server
1) install xcache cache accelerator
If the configure Times that generates xcache is wrong, if you don't report it, you don't need to solve the problem.
Solution:
First yum installs M4
Then yum installs autoconf
Regenerate the configure file
Compile and install again
2) after installation, this line prompt indicates that the installation is successful.
Note: this line of parameters need to remember that in the php.ini configuration file, when you add a xcache module, you need to specify the module file.
(xcache.so), and module files are stored in this directory
3) create xcache cache file
4) copy the xcache daemon to the root of the website. At the same time, you also need to copy a copy to the apache server
5) configure the php.ini file to make php support xcache
Restart the php-fpm service
6) testing
7) modify the time zone of php.ini
8) restart php-fpm and verify
5. Installation and use of Ab stress testing tools
Install it on the client and install it directly with yum.
1) the use of ab tools
2) the number of concurrent connections is also limited by the number of files that linux can open at the same time.
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.