Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hot Deploy a Java EAR to Minimize or Eliminate Downtime of an Application on a Server?

I have heard that this is what JavaRebel does but is there any other good way to deploy a new version of an EAR while allowing users to remain active on the previous version? We use JBoss for the application server...

like image 330
Ichorus Avatar asked Oct 21 '08 13:10

Ichorus


People also ask

What is the best deployment strategy to prevent the downtime?

Blue-green deployment is a technique that reduces downtime and risk by running two identical production environments called Blue and Green. At any time, only one of the environments is live, with the live environment serving all production traffic.

How do I deploy a website without downtime?

A Blue-Green deployment is a relatively simple way to achieve zero downtime deployments by creating a new, separate environment for the new version being deployed and switching traffic into it. A rollback happens just as easily, with a traffic switch to the old version.

What does Hot deploy mean?

Hot deployment is the process of adding new components (such as WAR files, EJB Jar files, enterprise Java beans, servlets, and JSP files) to a running server without having to stop the application server process and start it again.


2 Answers

It's not what JavaRebel does. JavaRebel (according to description) hot-replaces the classes in memory. It's not acceptable in the case of existing connections to the system, since the updated classes may break the client's logic.

Once a company I was working for had a similar problem, and it was solved this way:

  • a smart router was used as a load-balancer
  • the new version was deployed to 50% of the nodes of the (new) cluster
  • new connections were delivered strictly to these updated nodes, old ones were balanced between old nodes
  • old nodes were took off-line (one-by-one, to keep number of clients per node within limits)
  • at the same time, new version was deployed to off-line "old" nodes and they were brought up as new nodes
  • due to EJB clustering, the sessions and beans were picked up by other old nodes
  • eventually (in a few hours), only one old node left, having a single instance of old version and all clients using old version were connected to it
  • when the last old client got disconnected, that node was too brought down

Now, I'm not a networking guy, and cannot give you many details (like what was the router hardware and such). My understanding this can be set up pretty easy, except, if I remember right, we had to setup an additional Weblogic domain to deploy new versions of the application (otherwise it would be conflicting with the old one on JNDI names).

Hope that helps.

P.S. Ichorus provided a comment saying that the app is deployed on clients' servers. So the router trick may be not feasible. Now, I see only one viable solution right now ( it's 21:52 now, I may overlook things :) ) --

  • Develop new version with "versioned" JNDI names; e.g. if Customer bean was under ejb/Customer in version 1, in version 2 it would be under ejb/Customer2
  • Have a business facade in the application with a stable basic interface (Factory-style) which, when asked for Customer bean, tries to find the highest-versioned JNDI name (not on every call, of course, can cache for a hour or so). That facade could (and should) be deployed as a separate application -- and never or very rarely updated
  • Now every new client would get access to the latest application deployed, and the applications won't conflict.

This approach takes a careful planning and testing, but should work IMHO.

I recently modified a few applications in a similar way to let them coexist in the same domain (before they used the same JNDI name for different data sources).

like image 109
Vladimir Dyuzhev Avatar answered Sep 19 '22 00:09

Vladimir Dyuzhev


As I understand WebLogic has a feature called parallel deployment to eliminate downtime during EAR version upgrade. You can deploy the new version without stopping the existing application and once the new version deployed successfully you can switch over transparently from the old one to new one.

I am not sure if other application server supports this.

Ref: http://edocs.bea.com/wls/docs100/deployment/redeploy.html#wp1022490

like image 28
Rejeev Divakaran Avatar answered Sep 18 '22 00:09

Rejeev Divakaran