Tomcat: Deploying new verson without site downtime

We have running application on a server with Apache HTTP server in front and Tomcat server behind it as a servlet engine. When we deploy a new version of the application on Tomcat server, we have to shutdown the site (application context), deploy a new version (DB updates + new WAR) and start the server afterwards. Also, there are some backup things done before each deploy and initial testings after starting the application again, so this all make our site not available from 10 to 30 mins (sometimes even more).

Is there some deployment strategy with the server environment, like I have described above, for deploying a new version, so that we do not have site downtime? (Please, also reconsider of possible data changes in DB during a deployment of a new version, handling open HTTP session which started before deployment...)
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Hello drazen_nikolic,

If you do not want to have any downtime while deploying a new version of your WAR - you would need 2 servers with Tomcat. (virtual servers is also a solution, even if on the same physical server). While you're a updating the first server - the second is taking all users requests. This also means that you need a loadbalancer in front of both servers holding session informations (or with session replication technology).

With DB updates, it's quite different, as you have only one database, even if you have installed clusters.

As I have the same problematics you are talking about, I have resolved it by scripting everyting.
This way, when I need to deploy a new WAR and make some updates to the database I only launch a shell script which :
- stops tomcat server
- replace the WAR in webapps
- dump the database (just in case)
- updates the database with SQL script file (if the file is present)
- dump again the database (just in case, again)
- erase the work/ folder (as I already had troubles with)
- starts tomcat

This way, the website is unavailable for 1 minute only.

I'm currently thinking of programming the deployment process, so this would be done at 11pm, for example, with a SMS sent me on my phone with deployment status, as I already receive SMS when something goes wrong on the server.

Hope this helps

Best regards

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
drazen_nikolicAuthor Commented:
Hello evquen,

Thank you for your comment. We already do the similar procedure like you wrote. It is an interesting idea, though, to schedule a job which will execute the shell script or ruby code to perform the deployment at some time around midnight.

But I would like to have a solution which will result in no site downtime. How it can be managed tha session could be shared among differnet Tomcat instances, or how that session replication could be achieved?

Any tips, examples, URLs?
drazen_nikolicAuthor Commented:
It is not what I was looking for but nobody else, except you, responded. So you get all the points. :) Thank you, anyway. Regards
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.