0

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?

Scott Warren
  • 141
  • 5
  • 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 03 '10 at 09: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 06 '10 at 03:32

2 Answers2

1

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
mtomis
  • 111
  • 3
0

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

Mircea Vutcovici
  • 17,619
  • 4
  • 56
  • 83
  • What is AS? Application Servers? – Scott Warren Dec 06 '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: http://en.wikipedia.org/wiki/Autonomous_system_%28Internet%29 – Mircea Vutcovici Dec 07 '10 at 03:19