31

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.

Geo
  • 3,101

8 Answers8

32

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.

EEAA
  • 110,608
12

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.

Kief
  • 301
6

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.

3

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.

Claude
  • 39
2

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.

matpie
  • 493
1

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.

einstiien
  • 2,608
0

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.

Joel Coel
  • 13,117
0

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.