Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a VPS with 4 GB of ram and 8 cores and about 200K Visits per day. I have DirectAdmin Installed and I always see a huge number of PIDs for httpd and mysqld in DirectAdmin Service Monitor.

e.g. about 40 number of PIDs for mysqld and it increases in a while. I have CSF installed and configured httpd.conf/my.cnf sometimes this load prevents the server from responding and it freezes.

Administrators installed 32bit Centos and defined only 512 MB for SWAP

Swap:       524280          4     524276

any ideas to fix this ?


share|improve this question
From memory, mysql opens a new thread, with a new PID, on every new connection. Depending on how apache is configured, it may also spin up a new thread for each connection. How do you know that your server freezing issues are caused by the number of mysqld and httpd processes? – growse Jul 16 '12 at 19:32
@growse is right. Apache and MySQL spawning lots of processes is normal. Are you sure this is actually the cause? what are the results of free -h and top? – kce Jul 16 '12 at 20:09
As noted above, several msqld and httpd procs are normal. Swap is only used when your RAM is maxed out, and it needs more memory. If you're not hitting your limit on RAM, then you need to look elsewhere for the source of your problems. From what you've posted, low swap size doesn't look to be the issue at hand. However, if you really want to increase the swap size, I've listed some guides below to help. – nojak Jul 16 '12 at 20:18
Thanks Everyone, because when number of PIDs grows up my server stops responding and if I stop mysqld and httpd It will be fine. (top says the same thing and in load time I only have a few mb free). – Zim3r Jul 17 '12 at 5:46
up vote 1 down vote accepted

If you want to add swap space, I'd suggest reading's documentation on the subject.

You may also find this guide from Techotopia helpful.

CentOS recommends your swap being at 6GB for your particular build.

For swap file size, refer to this documentation from

Swap should equal 2x physical RAM for up to 2 GB of physical RAM, and then an additional 1x physical RAM for any amount above 2 GB, but never less than 32 MB.

So, if:

M = Amount of RAM in GB, and S = Amount of swap in GB, then

If M < 2
    S = M *2

S = M + 2
share|improve this answer
Thanks nojak, does it make any difference if I switch to 64bit OS and add 6GB (4+2) of SWAP ? – Zim3r Jul 17 '12 at 5:48
It won't make any difference if you're not using all of your RAM. Swap only gets used if you use up all of your RAM. 64-bit won't do a whole lot for you, either, unfortunately. You can always try it, though. Never hurts to do some testing. – nojak Jul 17 '12 at 16:14

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.