Question about "net.core.somaxconn" in sysctl.conf

Hi Rahul. In the post https://easyengine.io/tutorials/php/fpm-sysctl-tweaking/ you recommended this tweek:

echo "net.core.somaxconn=65536" >> /etc/sysctl.conf 
sysctl -p

But in https://easyengine.io/tutorials/linux/sysctl-conf/ you recommended configuration file have this: # Increase number of incoming connections net.core.somaxconn = 4096

and now? What is the most recommended value?

PS: I’m having problems with PHP-FPM 5.6.28 reaching 100% cpu load for a few minutes. My server is Amazon EC2 m3.xlarge and the number of concurrent users is only 15 to 35.

I’m having problems with PHP-FPM 5.6.28 reaching 100% cpu load for a few minutes. My server is Amazon EC2 m3.xlarge and the number of concurrent users is only 15 to 35.

Your problem doesn’t indicate any issue with net.core.somaxconn settings.

It seems more like a problem caused by some bad php-mysql code.

As your CPU is 100% already, more PHP processes won’t help.

The article is meant for servers where PHP can’t accept more connection even before CPU is reached 100%.

1 Like

Thx Rahul. I’m trying to figure out what the problem is. I’m also suspecting it is triggered by some plugin or theme (I use Wordpress). This is the error in the nginx log when the CPU stays for a few minutes at 100%[error] 1230#0: *45952 recv() failed (104: Connection reset by peer) while reading response header from upstream

To finalize this tweek question I should keep the file sysctl.conf with “net.core.somaxconn = 4096” or increase to 65536?

Taking advantage of his vast knowledge in the area I have 2 more questions:

  1. I’m using m3.xlarge (15GB Ram and 4Vcpus) -> http://www.ec2instances.info/?selected=m3.xlarge

This is my www.conf config:

include=/etc/php/5.6/fpm/pool.d/*.conf
[global]
pid = /run/php/php5.6-fpm.pid
error_log = /var/log/php5.6-fpm.log
;syslog.facility = daemon
;syslog.ident = php-fpm
log_level = notice
emergency_restart_threshold = 10
emergency_restart_interval = 1m
process_control_timeout = 10s
; process.max = 128
; process.priority = -19
daemonize = yes
;rlimit_files = 1024
;rlimit_core = 0
;events.mechanism = epoll
;systemd_interval = 10

In your opinion, should I continue with “dynamic” and increase or decrease these values or switch to “ondemand”? And what values would you recommend in ondemand?

  1. What is the best debugging plugin for Wordpress to clearly identify the source of my problem?

Ah! A curiosity: I’ve learned a lot from you and Nitun. I hired rtCamp to optimize an AWS server for me in july 2013.

Hi Rahul. I think I figured out the problem. I see that when the four CPU cores of my EC2 instance reached 100% because of PHP-FPM there were dozens of extra threads in the database (AWS RDS m3.medium Mysql 5.7.11).
Searching the internet, I discovered that it is not a good idea to have mysql.allow_persistent = On turned on in php.ini. Then I switched to OFF and also set to my.cnf interactive_timeout = 180 and Wait_timeout = 180

So I’d like to take your patience and ask for tips of my current php.ini attached phpini.txt (4.3 KB)

So far it seems that has solved my problem, but I am concerned that it may have other misconfigurations that may cause more problems in the future.

PS: If you think I’m abusing your goodwill, I can pay you to do an analysis and give me improvement tips. :wink: