HP-FPM: Socket vs TCP/IP and sysctl tweaking

Tweaking FPM config

You may also need to tweak PHP-FPM config to match new sysctl.conf settings.

Open PHP-FPM pool config file:

vim /etc/php5/fpm/pool.d/www.conf

Look for line:

;listen.backlog = 128

Change it to:

listen.backlog = 65536

Restart php5-fpm service.

service php5-fpm restart

Using TCP/IP for FPM

Sockets are slightly faster as compared to TCP/IP connection. But they are less scalable by default.

If you start getting errors like below (as faced ovidiu here

connect() to unix:/var/run/php5-fpm.sock failed or **apr_socket_recv: Connection reset by peer (104)**

Then it means you need to either switch to TCP/IP or tweak with linux-system parameter so that your OS can handle large number of connections.

Open PHP-FPM pool config file

vim /etc/php5/fpm/pool.d/www.conf

Replace line:

listen = /var/run/php5-fpm.sock

by line:

listen = 127.0.0.1:9000
Changes to Nginx

Next, open Nginx virtual-host config file(s).

Look for line

fastcgi_pass unix:/var/run/php5-fpm.sock;

Replace it with

fastcgi_pass 127.0.0.1:9000;

Important: Reload php-fpm and nginx so that changes can take effect.

service php5-fpm reload && service nginx reload

Sysctl.conf Tweaking

Finally, don’t forget to tweak Linux’s sysctl values by following this – https://rtcamp.com/tutorials/linux/sysctl-conf/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值