I have a Debian Squeeze Lighttpd server with PHP and MySQL, and also with XCache and Varnish set up.

I am quite new to this, but have tried as hard as I can to resolve this problem with no success.

Whether I use Lighttpd or Nginx or XCache or APC the problem remains.

Basically the server chugs along processing PHP perfectly fine, the RAM looks fine etc. Then suddenly it seems to grind to a halt and the PHP-CGI (or FPM) processes stack up and stack up, eating up all of my quad core CPU power and causing the whole server to become almost entirely non-responsive.

I have 4 sites on my server, 3 of which are quite low traffic and demand, and one of which is quite intensive and busy. So it's almost definitely that site causing it. However we got that site working on this (VPS) server before with a cPanel setup (that I want to avoid now due to cost and preference of Debian, etc.

Even when I remove all AJAX from the intensive site and lower traffic, it still does it.

There are also no obvious errors reported in the PHP, MySQL or lighttpd logs (I got them all working and check them regularly).

Here is the PHP part of my lighttpd.conf:

http:// pastebin.com/JwbFJ4YQ

(max requests set to 500 as recommended here, not 100% sure it's correct, but of course the problem happened in nginx too anyway!)

and here is my php.ini:

http:// pastebin.com/XHH0YMTd

and my MySQL my.cnf:

http:// pastebin.com/YPFjdfmf

Any thoughts? XCache only has 64mb allocated to it but that's what they recommended to start with and it never seems to use it all in its admin CP (that I notice). Both Varnish and XCache are working fine I think and the sites respond VERY fast until this lock up event happens (which it predictably always does).

  • 1
    don't run the bad processes? – mdpc Apr 3 '13 at 20:13
  • Have you looked through your access logs to see if you can correlate the outage with a specific HTTP request? – Zoredache Apr 3 '13 at 23:43
  • 1
    hm, that might be useful to do. Sounds very time-consuming though and also I honestly think MULTIPLE things do it. I tried spamming the AJAX chat room and it did it. Then I tried disabling all AJAX including the chat room, and it still happens frequently. I think it's just poorly setup somewhere... – Wave Apr 4 '13 at 1:50
  • Do you see processes with a D state in ps? – NickW Apr 4 '13 at 10:03

Fixed... I think!

The solution was to implement timeouts wherever possible throughout PHP and MySQL.

I won't go into detail but do a few Google searches and you'll find them.

They are things like:

mysql.connect_timeout (in php.ini)


interactive_timeout (I set to 10)

wait_timeout (I set to 20)

connect_timeout (I set to 20)

in MySQL's my.cnf file (I think that's all of them for my.cnf)

This seems to control things and keep the server up!

Thanks very much for all your help though :)


  • Oh, although I still get it a bit... ugh. haha :) – Wave Apr 7 '13 at 17:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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