Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Smooth redeployment of WAR in production?

I was wondering if there is a 'smooth way' of redeploying a Java WAR to a production server (no cluster, no OSGi)?

All I can come up with is stop server, update file, restart server. And 10 minutes beforehand I need to display a maintenance warning on the site.

What's your approach?

like image 227
stephanos Avatar asked May 31 '10 14:05

stephanos


4 Answers

First, hot-deploy doesn't always work. We spent so much time to make sure every new module is loaded and decided it's not worth the trouble. So what you are doing may sound bad but it's the most reliable way to deploy a new WAR.

Our current approach is to use a switch with load-balancer in front of all servers. We run at least 2 instances of the application servers. When we shutdown one server for maintenance, the traffic automatically goes to the other one.

Some of the switches are really inexpensive. If you don't have enough load to justify a new box and your 2 instances can run on the same box.

In some circumstances, the switches can actually save money. For example, we have a SSL page that used to use 6 boxes and now it runs fine on 2 boxes with SSL acceleration in the switch.

like image 85
ZZ Coder Avatar answered Nov 12 '22 18:11

ZZ Coder


You might have a look at JRebel, though I wouldn't use it in production. In production we do basically the same, though our boss keeps on dreaming of hot redeploys. Unfortunately they are supported mostly on paper - in most complex applications something always goes wrong with hot redeploys. The same is even truer for incremental hot redeploys...

like image 45
Bozhidar Batsov Avatar answered Nov 12 '22 19:11

Bozhidar Batsov


Some application servers do support redeployment without interruption of service. This is at least true for WebLogic, see Using Production Redeployment to Update Applications. Note that this is not hot deploy (and I would NEVER use hot deploy with production servers).

Without application server support, I'm afraid you won't be able to do real "smooth" redeployments. If you want to minimize downtime, one approach is to deploy the new application in parallel (on the same server or another one) and to change the routing rules when done. But clients will loose their session.

like image 20
Pascal Thivent Avatar answered Nov 12 '22 19:11

Pascal Thivent


Usually it's possible to optimize start-up time. Our web application starts with Jetty in 5-7 seconds. Other Java web servers are worse, because they start very slow.

Also, as I'm aware (not I did it), the front-end web server (such as apache, we use lighttpd) could be configured to hold request some period of time (up to 30 seconds on ours) while the Jetty is not ready. So, we just easily restart the Jetty while deploying, and users just have several seconds delay in worst case, which usually just looks like an Internet connection glitch.

like image 36
kan Avatar answered Nov 12 '22 19:11

kan