PHP-FPM高负载下的优化配置
2014-05-19 11:49
561 查看
http://www.zrwm.com/?p=54
When you running a highload website with PHP-FPM via FastCGI, the
following tips may be useful to you : )
如果您在运行一个高负载网站使用PHP-FPM管理FastCGI,下面的技巧也许对您有用
1. Compile PHP’s modules as less as possible, the simple the best
(fast); 尽量少安装PHP模块,最简单是最好(快)的
2. Increas PHP FastCGI child number to 100 and even more. Sometime,
200 is OK! ( On 4GB memory server);
把PHP FastCGI子进程数调到100或以上,在4G内存的服务器上200就可以。
注: 如果内存小2G,调为64就好.我的服务器内存为8G,把PHP FastCGI子进程数调整到300, 建议使用压力测试获取最佳值。
3. Using SOCKET PHP FastCGI, and put into /dev/shm on Linux;
使用socket连接FastCGI,并且放到linux系统的/dev/shm中
注: 在php-fpm.conf里设置 listen_address = /tmp/nginx.socket 就可以通过socket连接 FastCGI了.
/dev/shm是内存文件系统,放在内存中当然更快。
4. Increase Linux “max open files”, using the following command (must
be root):
调高linux内核打开文件数量,可以使用以下命令(必须是root帐号)
# echo ‘ulimit -HSn 65536′ >> /etc/profile
# echo ‘ulimit -HSn 65536 >> /etc/rc.local
# source /etc/profile
注: 我是修改/etc/rc.local, 加入ulimit -SHn 51200,不过竟然没生效
解决:
vi /etc/security/limits.conf
文件最后加上
* soft nofile 51200
* hard nofile 51200
5. Increase PHP-FPM open file description rlimit:
增加 PHP-FPM 打开文件描述符的限制:
编辑php-fpm.conf,找到rlimit_files的项,将值设置为4096或是更高,然后重启PHP-FPM.
# vi /path/to/php-fpm.conf
Find “rlimit_files = 1024″
Change 1024 to 4096 or higher number.
Restart PHP-FPM.
6. Using PHP code accelerator, e.g eAccelerator, XCache. And set
“cache_dir” to /dev/shm on Linux.
使用php代码加速器,例如 eAccelerator, XCache.在linux平台上可以把`cache_dir`指向 /dev/shm
When you running a highload website with PHP-FPM via FastCGI, the
following tips may be useful to you : )
如果您在运行一个高负载网站使用PHP-FPM管理FastCGI,下面的技巧也许对您有用
1. Compile PHP’s modules as less as possible, the simple the best
(fast); 尽量少安装PHP模块,最简单是最好(快)的
2. Increas PHP FastCGI child number to 100 and even more. Sometime,
200 is OK! ( On 4GB memory server);
把PHP FastCGI子进程数调到100或以上,在4G内存的服务器上200就可以。
注: 如果内存小2G,调为64就好.我的服务器内存为8G,把PHP FastCGI子进程数调整到300, 建议使用压力测试获取最佳值。
3. Using SOCKET PHP FastCGI, and put into /dev/shm on Linux;
使用socket连接FastCGI,并且放到linux系统的/dev/shm中
注: 在php-fpm.conf里设置 listen_address = /tmp/nginx.socket 就可以通过socket连接 FastCGI了.
/dev/shm是内存文件系统,放在内存中当然更快。
4. Increase Linux “max open files”, using the following command (must
be root):
调高linux内核打开文件数量,可以使用以下命令(必须是root帐号)
# echo ‘ulimit -HSn 65536′ >> /etc/profile
# echo ‘ulimit -HSn 65536 >> /etc/rc.local
# source /etc/profile
注: 我是修改/etc/rc.local, 加入ulimit -SHn 51200,不过竟然没生效
解决:
vi /etc/security/limits.conf
文件最后加上
* soft nofile 51200
* hard nofile 51200
5. Increase PHP-FPM open file description rlimit:
增加 PHP-FPM 打开文件描述符的限制:
编辑php-fpm.conf,找到rlimit_files的项,将值设置为4096或是更高,然后重启PHP-FPM.
# vi /path/to/php-fpm.conf
Find “rlimit_files = 1024″
Change 1024 to 4096 or higher number.
Restart PHP-FPM.
6. Using PHP code accelerator, e.g eAccelerator, XCache. And set
“cache_dir” to /dev/shm on Linux.
使用php代码加速器,例如 eAccelerator, XCache.在linux平台上可以把`cache_dir`指向 /dev/shm
相关文章推荐
- php-fpm的配置和优化
- 【汇总】PHP-FPM 配置优化
- php-fpm的配置和优化
- php-fpm的配置和优化
- Nginx+PHP-fpm高负载优化及压力测试方法
- php-fpm.conf配置说明(重点要修改和优化的地方)
- Nginx&&PHP-FPM配置及优化指南(上)
- 高流量站点NGINX与PHP-fpm配置优化
- 高流量站点NGINX与PHP-fpm配置优化
- php-fpm安装、配置与优化
- 【汇总】PHP-FPM 配置优化(转)
- web大负载优化收集------php-fpm参数优化
- PHP-php-fpm配置优化
- 高流量站点NGINX与PHP-fpm配置优化
- 高流量站点NGINX与PHP-fpm配置优化
- 高流量站点NGINX与PHP-fpm配置优化(译)
- 为高流量站点优化NGINX和PHP-fpm配置
- PHP与PHP-FPM的配置与优化
- 高流量站点NGINX与PHP-fpm配置优化
- nginx 及 php-fpm和系统ulimit 配置优化&cpu信息查看