1

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 ?

Thanks

4
  • 2
    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, 2012 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?
    – user62491
    Jul 16, 2012 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. Jul 16, 2012 at 20:18
  • 1
    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, 2012 at 5:46

1 Answer 1

1

If you want to add swap space, I'd suggest reading CentOS.org'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 CentOS.org.

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
Else

S = M + 2
2
  • Thanks nojak, does it make any difference if I switch to 64bit OS and add 6GB (4+2) of SWAP ?
    – Zim3r
    Jul 17, 2012 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. Jul 17, 2012 at 16:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .