I have a Apache server which is very unstable, and many times a day I struggle to connect to apache. I can not figure out why, since it for me everything seems to be ok. The server have at all time "plenty" of free resources. The server is a Linode 4098 with 4GB ram, 48GB HD, and 2 CPUs.
I'm using mod_status to check apache status but I keep getting Connection timeout errors when i try access /server-status page.
My current apache conf
<IfModule mpm_prefork_module>
StartServers 3
ServerLimit 200
MinSpareServers 3
MaxSpareServers 5
MaxRequestWorkers 175
MaxConnectionsPerChild 100
MaxRequestsPerChild 20
</IfModule>
Almost every second apache request to /server-status fails with ERR_CONNECTION_TIMED_OUT.
What I cant understand is why this happens, as when I check server there is plenty of available resources and idle connections.
For example /server-status reports many available connections:
Parent Server Config. Generation: 1
Parent Server MPM Generation: 0
Server uptime: 1 hour 6 minutes 6 seconds
Server load: 0.09 0.15 0.14
Total accesses: 27206 - Total Traffic: 79.8 MB
CPU Usage: u3.92 s.77 cu0 cs0 - .118% CPU load
6.86 requests/sec - 20.6 kB/second - 3077 B/request
52 requests currently being processed, 1 idle workers
RRRCRRRRRRRRRRRRRRRRRRCRRC.RR.R.RRRRRRRRRCRRRRR_WCCRR.R..RR.....
................................................................
...............................................
And with uptime, i see that CPU is also available
load average: 0.05, 0.12, 0.14
and there is available memory:
total used free shared buff/cache available
> Mem: 3.9G 1.3G 413M 81M 2.1G 2.3G
Anyone have some idea about what could be wrong?
UPDATE:
As requested, here is a snippet of the access log. (99% is requests regarding tracking stats by calling /api2/counting/count script-handler)
4.139.128.194 - - [23/Jan/2017:11:38:36 +0000] "POST /api2/counter/count?r=1485171514298 HTTP/1.1" 200 441 "-" "WriteDiary4.72"
176.38.149.76 - - [23/Jan/2017:11:38:36 +0000] "POST /api2/counter/count?r=1485171517077 HTTP/1.1" 200 454 "-" "WriteDiary4.72"
67.84.227.131 - - [23/Jan/2017:11:38:36 +0000] "GET /keepalive?471:1485171524866 HTTP/1.1" 200 469 "https://www.writediary.com/notes" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.79 Safari/537.36 Edge/14.14393"
122.178.156.252 - - [23/Jan/2017:11:38:36 +0000] "POST /api2/counter/count?r=1485171515804 HTTP/1.1" 200 441 "-" "WriteDiary4.72"
82.137.13.18 - - [23/Jan/2017:11:38:37 +0000] "POST /api2/counter/count?r=1485171525558 HTTP/1.1" 200 441 "-" "WriteDiary4.72"
103.199.35.221 - - [23/Jan/2017:11:38:37 +0000] "POST /api2/counter/count?r=1485171515470 HTTP/1.1" 200 441 "-" "WriteDiary4.72"
95.218.142.245 - - [23/Jan/2017:11:38:37 +0000] "POST /api2/counter/count?r=1485171516264 HTTP/1.1" 200 441 "-" "WriteDiary4.72"
47.31.143.106 - - [23/Jan/2017:11:38:37 +0000] "POST /api2/counter/count?r=1485171515787 HTTP/1.1" 200 441 "-" "WriteDiary4.72"
94.139.128.194 - - [23/Jan/2017:11:38:37 +0000] "POST /api2/counter/count?r=1485171515619 HTTP/1.1" 200 441 "-" "WriteDiary4.72"
120.188.33.198 - - [23/Jan/2017:11:38:37 +0000] "POST /api2/counter/count?r=1485171515867 HTTP/1.1" 200 454 "-" "WriteDiary4.72"
47.29.174.163 - - [23/Jan/2017:11:38:37 +0000] "POST /api2/counter/count?r=1485171515122 HTTP/1.1" 200 441 "-" "WriteDiary4.72"
85.115.224.151 - - [23/Jan/2017:11:38:37 +0000] "POST /api2/counter/count?r=1485171515453 HTTP/1.1" 200 441 "-" "WriteDiary4.72"
47.11.219.147 - - [23/Jan/2017:11:38:37 +0000] "POST /api2/counter/count?r=1485171516596 HTTP/1.1" 200 441 "-" "WriteDiary4.72"
61.5.53.52 - - [23/Jan/2017:11:38:37 +0000] "POST /api2/counter/count?r=1485171520665 HTTP/1.1" 200 441 "-" "WriteDiary4.72"
116.102.205.20 - - [23/Jan/2017:11:38:37 +0000] "POST /api2/counter/count?r=1485171516590 HTTP/1.1" 200 454 "-" "WriteDiary4.72"
101.60.31.133 - - [23/Jan/2017:11:38:37 +0000] "POST /api2/counter/count?r=1485171516802 HTTP/1.1" 200 441 "-" "WriteDiary4.72"
47.31.147.213 - - [23/Jan/2017:11:38:37 +0000] "POST /api2/counter/count?r=1485171515431 HTTP/1.1" 200 5131 "-" "WriteDiary4.72"
186.78.73.222 - - [23/Jan/2017:11:38:37 +0000] "POST /api2/counter/count?r=1485171669305 HTTP/1.1" 200 454 "-" "WriteDiary4.72"
112.79.186.36 - - [23/Jan/2017:11:38:38 +0000] "POST /api2/counter/count?r=1485171736857 HTTP/1.1" 200 454 "-" "WriteDiary4.72"
94.139.128.194 - - [23/Jan/2017:11:38:38 +0000] "POST /api2/counter/count?r=1485171516605 HTTP/1.1" 200 441 "-" "WriteDiary4.72"
24.236.88.161 - - [23/Jan/2017:11:38:38 +0000] "POST /api2/counter/count?r=1485171516752 HTTP/1.1" 200 441 "-" "WriteDiary4.72"
150.31.100.192 - - [23/Jan/2017:11:38:38 +0000] "POST /api2/counter/count?r=1485171517315 HTTP/1.1" 200 454 "-" "WriteDiary4.72"
12.181.196.67 - - [23/Jan/2017:11:38:38 +0000] "GET /keepalive?50412:1485171517975 HTTP/1.1" 200 501 "https://www.writediary.com/notes" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.99 Safari/537.36"
112.198.75.139 - - [23/Jan/2017:11:38:38 +0000] "POST /api2/counter/count?r=1485171408169 HTTP/1.1" 200 4794 "-" "WriteDiary4.72"
114.125.201.114 - - [23/Jan/2017:11:38:38 +0000] "POST /api2/counter/count?r=1485172944904 HTTP/1.1" 200 441 "-" "WriteDiary4.72"
SOLUTION:
I had to upgrade server to allow more workers.
As each Apache connection reqires about 30MB or Ram, the server was pushing the limits 4GB RAM gives = 4000MB / 30MB = 133 connections max… and when some of the memory is allocated to mysql and other system functions, in practice only 3.5GB is available, giving a max closer to 100 connection.
When upgrading to 8GB RAM, max limit is closer to 250 connections, which makes everything run smooth. In fact, after rescale RAM, server-status reported 200 requests was simultanously processed by Apache for many hours in peak time. Thats would explain why the server struggeled in peak time with a limit closer to 100..
Best Answer
can you please post the apache access log
you can find logs if you are using ubuntu by using this command
but it varies according to your platform