PHP-FPM High Load Tips (php-fpm on highload tips)
Original address: http://hi.baidu.com/pibuchou/blog/item/7cbccff0a3b77dc60b46e024.html
?
PHP-CGI (FASTCGI) leading to Nginx 502 Bad Gateway
Nginx frequency Explosion 502 Bad Gateway error, read the online tutorial, still not completely solved.
At present I summarize the way to solve 502 bad Gateway:
1. Depending on the performance of the server, increase the value of Max_children in php-fmp.conf, I currently use 15.
2. Use the reload parameter to reload the PHP-FPM periodically. The main reason is that PHP script execution time is too long, overload PHP-FPM can eliminate this problem. How to completely solve the php-cgi script takes up a lot of memory and causes 502 errors to be further explored, the current practice is a good way.
Specifically, use crontab to let PHP-FPM smooth restart, which does not affect the operation of PHP script.
*/10 * * * */USR/LOCAL/PHP/SBIN/PHP-FPM Reload
?
?
When do you running a highload website with? php-fpmvia FastCGI, the following tips is useful to you:)
These tips may be useful if you have a high-load site that uses php-fpm to manage fastcgi:)
1. Compile PHP ' s modules as less as possible, the simple and the best (fast);
1. Install PHP modules as little as possible, the simplest is the best (fast)
2. Increas PHP FastCGI Child number to + and even more. Sometime, ok! (on 4GB memory server);
2. Put your PHP FastCGI the number of sub-processes to 100 or more, on the 4G memory Server 200 can
> Note: My 1g test machine, open 64 is the best, we recommend the use of stress testing to get the best value
3. Using SOCKET PHP FastCGI, and put Into/dev/shm on Linux;
3. Using the socket connection fastcgi, The Linux operating system can be placed in the/DEV/SHM
note: in php-fpm . CNF Set /tmp/nginx.socket can be connected via socket fastcgi,/DEV/SHM is a memory file system, put in memory will definitely be faster
4. Increase Linux "Max open Files", Using the following command (must be root):
# Echo ' ULIMIT-HSN 65536′>>/etc/profi LE
# Echo ' ulimit-hsn 65536 >>/etc/rc.local
4. Increase the number of open files in the Linux kernel, which you can use (Must be root account)
echo ' ulimit-hsn 65536′>>/etc/profile
source/etc/profile?
Note: I'm modifying/etc/ Rc.local, adding
to Ulimit-shn 51200
5. Increase? php-fpmOpen File Description rlimit:
# vi/path/to/php-fpm. conf
Find " 1024x768 "
Change 1024x768 to 4096 or higher number.
Restart? php-fpm.
5. Increase? php-fpm? Restrictions on opening file descriptors:
# vi/path/to/php-fpm. conf
Find " 1024x768 "
Change the 1024 to 4096 or higher.
Restart? php-fpm.
6. Using PHP Code Accelerator, e.g Eaccelerator, XCache. and set "Cache_dir" To/dev/shm on Linux.
6. Use PHP code accelerators, such as Eaccelerator, XCache. On the Linux platform, you can point the ' cache_dir ' to/dev/shm
?