Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm sure you've noticed that for many servers, the website loading time is quite long if you're the first visitor for a couple of hours. Do you have any idea why this is the case (is it just server cache?) and how to make the site fast even for that first visitor? Let's take a normal LAMP setup in this case. Thanks for your help!

share|improve this question
In the case of most database engines, per database configuration for "AUTOCLOSE" or similar feature can be a culprit. – Adam Caviness Apr 3 '12 at 13:00
up vote 8 down vote accepted

There lots of potential causes. There's almost certainly not just one single reason.

A few possibilities:

  • The website is running under some pooling mechanism like FastCGI, mod_php/mod_perl/mod_python, etc. If either these or Apache are not configured to keep a minimum pool of servers, they will have to restart the application when a new request arrives and there are no servers available with that application already loaded.
  • The application uses a database connection pool. Same problem as above, except it's the database connection that needs to be re-established. Some relational databases can be very slow at opening a new connection (lots of overhead)
  • Various caching mechanisms (for high performance sites running load balancers or caches like memcached) along the way may need to refresh their information from the site directly if the information they have is stale. Could also apply to your browser's local cache: while it can normally ignore all the additional static files on a website like css, js, images, once these expire from the cache it needs to re-fetch them.
  • Sites may have maintenance activities like backups that take place when their load is low and the site is not being accessed.
  • Could even be as low level as the server's OS disk caching, which may have had its cache filled with other sites on the same server, pushing out the cached version of the site that hasn't been accessed in awhile (that's exactly what the disk cache is supposed to do, cache frequently used files, not infrequently used ones). The delay this should cause would most likely be very small and not noticeable to a human.

Mitigation strategies of course depend on what the actual cause is. But a few things that should normally be done:

  • Make sure Apache's MinSpareServers/MinSpareThreads and other performance settings are configured properly. Try to understand how, when and why Apache spawns more servers/threads.
  • Make sure any application servers like FastCGI are also properly configured to keep a sufficient pool available.
  • Correctly configure database connection pooling or keep a persistent database connection always open.
  • Ensure all your included files (css, js, etc) are cacheable and have reasonable expiry times.
share|improve this answer
I'd have put I/O caching at the top of my list. – symcbean Mar 7 '11 at 9:21

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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