I have a dedicated server that has 12GB of RAM and Dual Nahalem Quad Core processors. My site usually only has about 50-100 users online at a time (though once I get the server optimized I plan on advertising and estimate the number to be closer to 250, which should still be very easily handled by this server). For some reason, even with these low numbers, the site seems to lag quite often with almost no server load.

I have been using mysqltuner.pl to try to get some things setup better in my.cnf. At this user level the site runs about 200 queries per second and is about 50/50 reads/writes.When it comes to Apache settings, I would have absolutely no idea what to change.

I am mainly just looking for general suggestions of things to update to better optimize performance of the server so that pages actually load quickly. It is worth noting that the pages loaded fairly quickly until a few days ago when the average online increased by 3-4x (though the server load hasn't really increased).

This is a CentOS 5.4 server if that matters.

  • Does it lag all the time, or only when Apache is initially started? – pauska Nov 17 '09 at 23:08
  • It is basically all of the time, though it is fairly inconsistent and I can't seem to find a pattern as to when it speeds up or slows down. – James Simpson Nov 17 '09 at 23:14
  • Ok. I'm rubbish with finding Apache problems, but this could be a problem with persistent http connections clogging up. Do you see a very large amount of httpd's running that looks like they are just idling? Perhaps you should try to increase your maxservers limit. – pauska Nov 17 '09 at 23:16
  • I don't even see MaxServers in httpd.conf, could that be an issue? Or could it be named something else? I see MaxSpareServers, not sure if that is related. – James Simpson Nov 17 '09 at 23:18
  • Sorry, MaxClients. You could also try to raise MinSpareServers and MaxSpareServers a little. – pauska Nov 17 '09 at 23:23

The kind of numbers you are talking about are tiny, and as you observed load didn't change during that time period, so I don't expect this to be an issue of tuning apache or mysql directly.

In my experience of chasing issues like this down it's almost always ties into SQL. I would isolate what part of the page is consuming all of this time. Insert timer calls throughout the page in question and store the data somewhere you can review it (spit it to stderr and apache's error log if nothing else). Until you know the precise part of the code that is causing your slow down you will just be guessing.

Some possibilities:

  • A query into a table that has grown very large and is now slow (lacks index? needs pruning?)
  • A session table that is never pruned and has grown massive
  • A very subtle corruption (run through and optimize all your mysql databases to fix)
  • An ugly query that does heavy calculations every page load that could be optmized by saving the result in a cache.

I would also go back to basics and see if you can't find out what changed "a couple days ago". Was the page modified? Upgrades?

Another thing to check is I/O (iostat) to see if you may be I/O bound, though usually you will see symptoms in load for that.


Well it looks like the main issue was MaxClients being set really low (at 100). I raised this to 2000 and everything has been smooth sailing since then. Thank you pauska for pointing this out.

  • Happy to help, even though I was advicing you to check out areas of the config that I rarely modify myself. – pauska Nov 18 '09 at 16:33

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.