How do I deploy my Java WAR file on a production server without any downtime. I currently use Apache2 -> Jetty6 when I need to update the web application I unzip the war into the directory then restart the Jetty Service

/etc/init.d/jetty6 restart

This can take 5 minutes to restart is there another way? How do "big" websites do it?

In my experience hot deployment such as JBoss fails because the Garbage Collector doesn't collect everything and the service/process runs out of memory of has the situation improved?

  • 5 minutes to restart jetty seems like a lot. You should check the time needed to actually start your application. Even in a hot-deployment scenario you could have problems if the application takes a lot to restart. Oct 3, 2010 at 9:11
  • In windoze I have to shutdown the service before I can replace the (jar) files then restart the service. The issue applies if it's 5 minutes or 30 seconds there is still an outage. Oct 6, 2010 at 3:32

2 Answers 2


How about this. Create a script that does the following:

  • Start a second instance of jetty on port 8081.
  • Reload alternate apache configuration to send you traffic to 8081. I think this step should be fast. I use nginx which is instantaneous.
  • Kill 8080 jetty
  • Copy updated war into 8080 jetty webapps folder
  • Restart jetty on port 8080
  • Point apache back to 8080
  • kill jetty on 8081
  • You can use iptables to do the redirection from port 8080 to 8081, then remove it. Dec 2, 2010 at 1:47

You have the following things to take care:

  • sessions (Cookie based sessions)
  • database structure changes (that break the old application)

To keep the sessions across the restart of the application you will need a central place to keep the session, that is outside the application. E.g. 2 database with replication or memcached with replication.

For database changes you will have to make sure that the new application is pointing to a database with then new structure only. Do not remove fields or make the new structure to be incompatible with the old application. E.g. do not remove attributes or change their type.

Configure apache to use load balancing with 2 application servers (that could run on the same server). Use session stickiness. When one of the server is deployed the other can answer the requests.

Big sites are using a distributed AS with clusters of servers, round robin DNS, load balancers...


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .