2

I run a fairly busy webserver. It's pretty standard: Apache with mod_php on FreeBSD 7.1. It connects to a separate MySQL server. It serves lots of static images.

Users have been complaining of slow response times. Today I got very slow load times, then a "could not connect, try again" from my web browser.

Looking at top showed that the server was practically idle! Yet it was refusing any more connections. After a minute or so, it began responding again (though still slowly).

netstat -s includes

161796 listen queue overflows

but I'm not sure that's the problem, since I've increased somaxconn.

I must be hitting some resource limit. What else should I look at to diagnose the problem?

5 Answers5

1

First. Your bottleneck is almost certainly MySQL backend (or network between frontend and backend). So you've got idling frontend.
Second. You may wish to serve static via nginx/lighttpd if it's really highload webserver.
Third. I've posted quick manual about FreeBSD sysctl tuning, you may find it useful.

PS. There is also apache directive ListenBacklog you may wish to increase it along with MaxClients.

SaveTheRbtz
  • 5,621
  • 4
  • 29
  • 45
0

Apache's MaxClients is a big one. You can view what the current client/connection count is by enabling mod_status and running "apachectl status" or loading "http://localhost/server-status" in a web browser from the web server

Charles Hooper
  • 1,500
  • 9
  • 8
0

Depending on the scale of your static image serving, you might look into running something like lighttpd along side it to serve images. It tends to do much better with just static images. Lighttpd (lighty) is just that, light and will serve static content much more quickly and tuned a bit will likely not run into these limitations. The same could be done with Apache, but Apache is a bit hefty for just static content.

Xorlev
  • 1,845
  • 14
  • 12
0

Perhaps you've got a relatively small MaxClients, keepalives on with a long-ish timeout, and quite a lot of requests.

Browsers will generally hold a connection open for 30 seconds or so if you let them - so don't set keepalive too long.

Having keepalive on for a short period is beneficial to your users - but it does use up resources. Are you able to see the Apache scoreboard (i.e. server-status page?) ? Are all your slots consumed in 'K' state?

In general mixing application serving (your PHP app) and high-volume static files is a bad idea, they have different requirements. A fat Apache process (like ones with PHP in) is going to be wasting lots of memory serving static images that could be served by a thin one instead. Consider putting them in separate sets of physical servers, or on separate server instances on the same set of servers (with very different configs)

MarkR
  • 2,898
  • 16
  • 13
  • Thanks, that was it. The scoreboard showed that all slots were full. Decreasing the keepalive was the key. Thanks! –  Nov 13 '09 at 02:12
0

Is it doing reverse DNS lookups? (disable them)

Is avahi-daemon running? (kill it)

Florin Andrei
  • 1,148
  • 1
  • 11
  • 18