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.

link|improve this question

40% accept rate
20  
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
3  
@Bart Oh snap!! – mfinni Feb 4 '10 at 0:53
+1 just for making my day (PS: I am a developer myself) – RN. Apr 21 '10 at 5:57
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
feedback

7 Answers

up vote 19 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.

link|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
feedback

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.

link|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
feedback

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.

link|improve this answer
feedback

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.

link|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
feedback

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.

link|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
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. – ErikA 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
feedback

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.

link|improve this answer
feedback

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.

link|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
feedback

Your Answer

 
or
required, but never shown

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