Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

We have a web application (developed by a third party) that runs on Tomcat. We have been getting very bad performance from the application. The application developer is claiming that it is an Industry Best Practice to restart web servers every night, to free up all memory usage and start over.

From the customer perspective that alleviates their issue of the site crashing during the day, but from a SysAdmin perspective it is an awful solution.

We host 20 of these applications in different servers for different clients, and the coordination of making sure that all are being restarted every night just seems wrong.

share|improve this question

closed as primarily opinion-based by Falcon Momot, Jenny D, Bryan, TheCleaner, kce Jul 23 '13 at 16:50

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise.If this question can be reworded to fit the rules in the help center, please edit the question.

38  
Tell them that it's Industry Best Practice for application developers to find and fix their memory leaks. –  Bart Silverstrim Feb 4 '10 at 0:31
4  
@Bart Oh snap!! –  mfinni Feb 4 '10 at 0:53
1  
+1 just for making my day (PS: I am a developer myself) –  RN. Apr 21 '10 at 5:57
1  
Did he say servers or services? We hve a tomcat applicationm that needs the service restarting every night. If I don't do it, at some point in the future it will crash. I would rather not do it, but the service during the day is more important. –  Tubs May 11 '10 at 12:58
1  
Get some log file monitoring going and download some JVM monitoring tools. If stuff is crashing during the day you should see exceptions or something being logged--even if they're default exceptions. That'll give you some insight into the general nature of the error. Also, watch the JVM memory useage. Odds are really good they have a memory leak and you'll catch it if you watch the server JVM heap. Fight bad development with good sysadmin data. It destroys the "You just don't know what you're doing" defense and makes them actually have to answer for why things messed up. –  FloppyDisk Oct 31 '12 at 14:28

9 Answers 9

up vote 27 down vote accepted

This is certainly not a best practice. While it is good to restart your servers periodically just to make sure that everything comes up correctly, needing to restart nightly points to a very serious memory leak in the application.

share|improve this answer
1  
This is a very good point. If you never restart your servers as suggested below you might not know that you have certain services that dont start properly. Then, in the event of a power failure/hard restart your server may not come back right. –  einstiien Feb 4 '10 at 6:54
1  
+1. Monthly may make more sense - not only for a restart, but for a normal operation procedure to apply patches etc. I was once part of an admin team for about 1500 servers, 24/7, and every month there was a 3 night "rolling restart" scheduled, at which point all patches etc. would be put into the servers, too. This gicves some planning stability and a standard operating procedure. –  TomTom Apr 21 '11 at 19:54

There's a difference between "Best Practice", things that many people do for good reasons, and "Common Practice", things that many people do because they're lazy and/or ignorant.

Applications and (worse) servers that need to be routinely restarted or rebooted to keep running well are fairly common. But it's also a clear indication that you have a critical bug.

By making it SOP to restart an application on a regular basis, your company is hiding a serious bug under the carpet. This is inexcusable, the bug needs to be faced down and squashed, or it will come back to bite you later.

Ideally, your company should find a better developer. Unfortunately, this may lead to rather a lot of work to rewrite large tracts of your code. The fact that the developer either thinks that poorly written code is acceptable, or doesn't know enough to recognize the symptoms of buggy code, suggests the quality of the code is low. A good developer will be constitutionally incapable of leaving it in that state.

Given that you may not be in a position to replace the developer, a few suggestions:

  • See if you can have a better developer review the code and report their assessment to someone who can do something about it,
  • Have a look into profiling tools. If you've got the skills and/or inclination, try profiling the code yourself to find the leak and report it.

Even without getting into developer-oriented profiling tools, there are plenty of sysadmin-oriented tools for profiling and monitoring memory usage on Java applications. You should really set up monitoring of memory (particularly heap) on your production servers in any case. I'd recommend this even if you were running quality code. It may give you advance warning when your buggy apps are about to topple over.

But better yet, these should help you to gather proof that there is a leak, and may even indicate where the issue is in the application. This will give you better ammunition to lobby for it to be fixed.

share|improve this answer
1  
Actually, a lot of times it is the infrastructure that has the bug, and not the developer's code. We've had no end of trouble with J2EE apps that go into garbage-collection hell periodically on JBoss but work fine on other commercail application servers. So it might not be the developer's fault, but rather the deployment environment. –  rmalayter Mar 10 '11 at 22:40

The application developer is more likely claiming that it's in his own best interest for you to cover his ass by working around the unprofessional job he did. He may have stopped short of actually admitting that he wrote something with a whopping memory leak, but not very far short of it.

share|improve this answer

IMO Servers should be shut down as little as possible. It's more likely the App Developer built a shoddy application with a memory leak.

share|improve this answer
    
Absolutely - I think the OP needs to tell someone they need to find a better developer. –  Helvick Feb 3 '10 at 23:38
2  
There's a reason big companies pay big bucks for multiple nines uptime and why companies spend thousands on redundant power supplies, RAID, hot swap cages, etc., and it certainly isn't so that they only need to reboot once a day. –  Bart Silverstrim Feb 4 '10 at 0:30

Many answers here seem to fall way off the mark of practical solutions. They seem to eschew dogma - servers should never be restarted - why do we have 5 nines? fault tolerance? Well thats so when they are supposed to be up they stay up.

Also, to state its the cause of bad developers or bad development practice doesn't go to the root of the issue. It can be but more often than not its not bad application code. These issues are already built into much of the system code. Small memory leaks, Java heap and permgen issues if you are running lots of small apps as we do. Modern servers and the software they run are very complex. When you think of what a server like tomcat has to do - serve files, process web requests, network communications, database communications, etc., its doing a lot. IN that stack there a a heck of a lot of moving parts.

Proactively rebooting servers lets say once a week or month is smart and efficient in my view. If you are clustered and you rotate the servers you should not affect clients one bit. Clients will be much happier with the performance of your servers.

share|improve this answer

I have a script restart one of our webservers every night but that's more because of a poorly written java application rather than an industry standard. I would say that it isn't uncommon to restart the web services though. This might do the memory cleanup you're looking for and put less strain on the server as compared to a full restart.

share|improve this answer

A server should preferably never be restarted. That's one of the reasons why we have fault tolerance. If you have to restart your server because of your applications, then your applications are leaking memory and are badly constructed.

I have been working with Tomcat before, and I had the same problem, next time I will be working with a Java container I will look for another one, maybe JBoss or GlassFish.

Edit: If you have to restart it every night now, then you probably have to restart it more often if/when the load increases. Be sure to have solid applications, that's the best solution.

share|improve this answer
4  
I don't think I agree when you say a server should never be restarted. Servers should be restarted to apply security fixes. They should never need to be restarted for things other then planned maintenance though. –  Zoredache Feb 4 '10 at 1:15
    
It's true that some servers have to be restarted to apply security fixes. But if you have a good enough system, then you don't have to restart the system. It exists systems that are running year after year. You should aim for High Availability if you are serving a service on Internet. If you have a fault tolerant system like a cluster you could take down the nodes one by one and update them, when the service is still running. –  Jonas Feb 4 '10 at 1:30
1  
If you only have a single server and/or piece of hardware, there's no such thing as High Availability. You're doing it wrong if you only gave one server and your service is so critical that it can't tolerate 15 minutes of downtime every now and again to restart the server. If you do have a "zero downtime" application, then you will have a true HA system with multiple nodes. In this case, rebooting periodically for patches, etc is quite easy as you pointed out. –  EEAA Feb 4 '10 at 16:36
1  
"Next time ... I will look for another [Java container other than Tomcat]". I wouldn't blame Tomcat. I've been running production services on it for years, and every time I've had this problem it's turned out to be an application issue. "Be sure to have solid applications, that's the best solution" Exactly. Funnily enough, every other Java application server that I've used so far suffers similar problems when I run leaky code on it. That said, Tomcat 7 is supposed to have some kind of pro-active memory leak detection. –  Kief Jul 9 '10 at 15:26

The most frequent I've ever seen is weekly. Where I'm at now we're a windows shop, and we do it monthly over the weekend following Patch Tuesday.

share|improve this answer
    
When I started working at one place, I found that they had nightly reboots in place... That was horrible, especially since the server had around a 1-2% chance of not coming back up right (timing bug in the hard drive driver). Took some time to fix the "causes" for the reboots. Time WELL spent. –  Brian Knoblauch Apr 21 '11 at 19:53

While I agree it's not ideal to restart a server constantly, there are situations where it is neither the developer's fault nor the wrong thing to do. We have a well-behaved application that is leaking memory because of issues in the Python Popen library. It's an old application that will be retired soon, but it's business-critical. We have to keep it running with a minimum of fuss for our clients. So we've just decided to restart the server every night.

share|improve this answer

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