Z
Z
zdravnik2016-02-01 10:03:10
linux
zdravnik, 2016-02-01 10:03:10

Why is apache2 hanging?

It costs nginx/1.8.0 and httpd 2.2.15 on CentOS 6.7
mpm config is the following:


ServerLimit 500
StartServers 4
MinSpareServers 4
MaxSpareServers 8
MaxClients 500
KeepAlive On
KeepAliveTimeout 5
MaxRequestsPerChild 3000
ListenBacklog 512

The following options are enabled in sysctl.conf:
vm.overcommit_ratio = 100
vm.overcommit_memory = 2

But I'm not sure if these options affect the problem.
After simulating a high load or DDoS, using siege and then stopping the load, Apache often freezes, strace says the following:
[pid 63565] <... restart_syscall resumed> ) = 0
[pid 63565] clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7f9421beeab0) = -1 ENOMEM (Cannot allocate memory)
[pid 63565] write (2, "[Thu Jan 28 12:58:31 2016] [erro"..., 96) = 96
[pid 63565] rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
[pid 63565] rt_sigaction (SIGCHLD, NULL, {SIG_DFL, [], 0}, 8) = 0
[pid 63565] rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
[pid 63565] nanosleep({10, 0},
[pid 63565 ] <... nanosleep resumed> 0x7ffe6a49de20) = 0
[pid 63565] clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7f9421beeab0) = -1 ENOMEM (Cannot allocate memory)
[pid 63565] write(2, "[Thu Jan 28 12:58:41 2016] [erro"..., 96) = 96
[pid 63565] rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
[pid 63565] rt_sigaction(SIGCHLD, NULL, {SIG_DFL, [], 0}, 8) = 0
[pid 63565] rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
[pid 63565] nanosleep({10, 0 },

It happens that it doesn’t freeze for a long time, for example, for 1-2 minutes, and then wakes up and starts killing its children and working normally, and sometimes there are longer freezes, for example 20 minutes (I couldn’t wait longer, I restarted the piece of iron). But it also happens that it does not hang. If at the moment Apache hangs, you try to restart Apache, then the master process will die and no longer start because all the children remain hanging in the system.
In general, I've been fighting for a week now, I can not understand what the problem is.
Any ideas?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
A
Andrey, 2016-02-01
@VladimirAndreev

Do you really need Apache?

Z
zdravnik, 2016-02-01
@zdravnik

Apache is definitely needed.

S
synapse_people, 2016-02-01
@synapse_people

Awesome tips..
Try installing Apache 2.4. By the way, is swap enabled in the system?

N
neol, 2016-02-01
@neol

MaxClients 500

What were you hoping for when you set this value?
If you have an application, DBMS, reverse proxy, etc. on the same server, then MaxClients usually makes sense to set 2-8 times more cores (depending on the application), otherwise the server turns into a pumpkin.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question