Here is what I would like to achieve:
I have a web service A which I want to be able to deploy side by side with other web services of type A – different version(s). For now I assume 2 instances side by side. I need it because the service has a warm up stage, which takes some time to build up stuff from DB and only after it is ready it can start serving requests …
I was thinking to deploy to Tomcat6 context paths like: “/ServiceA-1.0”, “/ServiceA-2.0”
and then have a “virtual” context like “/ServiceA” which will point to the desired physical service e.g. “/ServiceA-1.0”. So external world will know about ServiceA, but internally, my ServiceA related stack would know about versioned ServiceA url ( there are more components involved but only ServiceA is serving outer world ). When new service is ready, I would just reconfigure the “virtual” context to point to a new service.
So far, I was not able to find out how to do this with Tomcat and starting to tkink it is not possible. I found suggestions to place Apache Server in front of Tomcat and do the routing there, but I do not want to enroll another piece of software unless necessary.
My questions are:
– is this kind of a “virtual” context and routing possible to do with Tomcat6?
– any other options, wisdom and lessons learned how to achieve this kind of service swapping scenario?
Best,
Jozef
Given the warm up period that you mention I assume that you want more or less uninterrupted service when you switch implementations. This really is easy to handle with an Apache in front.
I typically enjoy the flexibility I get from this extra layer. Apache is not too invasive on your system. Plus – if you run on unix – it’s trivial (read: default) to have Apache listen on port 80 while you’ll have to go extra miles to make tomcat listen on port 80 and not run as root.
If you have never touched Apache, be assured that it’s easy to learn in short time. Especially when you don’t need the full power that it brings. Configuring a reverse proxy (or mod_jk) is well documented everywhere. And the feature you mention is a hybrid of reverse proxy and load balancer – even if you only have one server to balance the load “between”, you’ll have two different contexts/versions.
Don’t fear the Apache, you’re on the right path 🙂