Apache Server Issues

I’ve been chasing a DNS ghost for a while now with my server. Sites would load fine at times, but occasionally the initial load would lag up to 15 seconds. I couldn’t think of any changes I had made to the server configuration, so I started thinking about DNS. The logic was that the DNS was struggling to resolve the initial domain and causing the delay. Once resolved, the sites seemed to work fine – another point for the DNS theory.

In actuality, my Apache2/Mysql configuration was to blame. I had installed the default values for both (answering the popups during installation to the best of my ability), and hadn’t really changed much. Because the problem developed slowly as traffic to the server increased, it was difficult to assign blame to a configuration that had previously been working without problems.

With a helpful post from Atomm (owner of Gamers Radio), at Earnersforum.com I started investigating the Apache2/Mysql configuration and found it was lacking. The sites were slow to load because Apache was serving the maximum number of clients already through its MaxClients setting and Mysql was not optimized to address my database requirements. Once Apache had accepted a request and (and assigned one of the MaxClients spots) things worked fine for that user, but were causing a delay for others trying to connect. The Mysql configuration, although not as big an issue as the Apache settings, was likely causing its own access delays to the databases as well.

The solution was to increase the MaxClients setting on the server to 512 instead of the 150 it was previously set to. Since this was higher than the ServerLimit default would allow, I had to change that to match. The resulting file looked like this:


# StartServers ……… number of server processes to start
# MinSpareServers …… minimum number of server processes which are kept spare
# MaxSpareServers …… maximum number of server processes which are kept spare
# MaxClients ……….. maximum number of server processes allowed to start
# MaxRequestsPerChild .. maximum number of requests a server process serves
# ServerLimit ………. Sets ceiling for MaxClients, default 256.
ServerLimit 512


StartServers 15
MinSpareServers 15
MaxSpareServers 10
MaxClients 512
MaxRequestsPerChild 0

# pthread MPM
# StartServers ……… initial number of server processes to start
# MaxClients ……….. maximum number of server processes allowed to start
# MinSpareThreads …… minimum number of worker threads which are kept spare
# MaxSpareThreads …… maximum number of worker threads which are kept spare
# ThreadsPerChild …… constant number of worker threads in each server process
# MaxRequestsPerChild .. maximum number of requests a server process serves

StartServers 12
MaxClients 512
MinSpareThreads 25
MaxSpareThreads 75
ThreadsPerChild 25
MaxRequestsPerChild 0


That being done, I referenced an excellent article at databasejournal.com to optimize the Mysql configuration to address the database issue.

The end result seems to be a much improved system – although I’ll have to monitor it for the next few days to be sure. Hopefully, this will seriously increase the responsiveness of my websites which will likely have a small impact on individual site revenue


Comments are closed.