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 wondering how often apache and mysql should be restarted (in particular having 150K hits/week), and what would be the actual benefit in restarting every certain time.

share|improve this question

If you're system is properly tuned and your application doesn't have any issues like memory leaks, you should only every have to restart them to apply patches.

share|improve this answer

Apache and MySql by themselves should be free of memory leaks. Most databases servers run better the longer they have been up. However, modules which are compiled into Apache like PHP often have memory leaks. The Apache mpm module automatically recycles processes after 10,000 requests. You can change the MaxRequestsPerChild to something different, but 10,000 is a reasonable default.

share|improve this answer
What does this mean: Most databases servers run better the longer they have been up? What does better mean? – Tshepang Jul 19 '11 at 22:57

Apache does not need regular restarting; nor should mysql.

Apache running in prefork mode can recycle its child processes using MaxRequestsPerChild; this is a good thing as it defends against slow memory leaks etc.

MySQL should not be restarted regularly, as restarting it will cause a service outage. Restarting MySQL needs to wait for the engines to start up, and will also clear out the cache causing performance to suck until it warms up. We seem to find that it needs restarting from time to time[1] because of address space fragmentation, but this should not happen so much on a 64-bit system, which new installations should always go on to.

[1] e.g. every 9 months on a busy server with > 100 queries per second average

share|improve this answer

You should avoid restarting MySQL whenever possible for performance reasons. MySQL uses lots of memory to cache data pages and indexes. When you restart MySQL, all cached pages are freed and you need some time to warm up caches. On highly loaded sites database restart could cause performance problems.

Your site is not heavily loaded (150k hits/week gives only 1req/4s), so MySQL restart should not cause big problems.

share|improve this answer

In order to understand when a system or service needs to be rebooted you first need to understand why. Memory leaks are the most common reason but there may be others, such as poorly written software (all too common!) that doesn't perform proper internal housekeeping, such as closing file handles when they are no longer required. While not being the same as a memory leak the symptoms are the same. Both Apache and MySQL are known to be very stable (unless you're running an alpha or beta version) and can run for years without issue. Normally the operating system will need rebooting to apply patches long before either application will require it.

share|improve this answer

Your Answer


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