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

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?

share|improve this question
    
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. –  Cristian Vat Oct 3 '10 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. –  Scott Warren Oct 6 '10 at 3:32
add comment

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
share|improve this answer
    
You can use iptables to do the redirection from port 8080 to 8081, then remove it. –  Mircea Vutcovici Dec 2 '10 at 1:47
add comment

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...

share|improve this answer
    
What is AS? Application Servers? –  Scott Warren Dec 6 '10 at 20:46
    
I am referring to Autonomous System. You can use a multi-homed geographically distributed AS to have a better redundancy, latency and fallback in case of one of your ISPs is down. See: en.wikipedia.org/wiki/Autonomous_system_%28Internet%29 –  Mircea Vutcovici Dec 7 '10 at 3:19
    
Thanks for the clarification. –  Scott Warren Feb 7 '11 at 22:07
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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