0

Similar question to, "Does it make sense to have multiple tomcat instances on the same server?" but in this case the Tomcats are running on a VM.

I know the answer probably is "it depends," but I'd like to explore the issue. When does it make sense? What are the VM specific considerations?

Reasons I've heard: 1) JVMs are somehow limited in their ability to use the resources available. So allocating more than one instance of tomcat will make better use of resources. Not sure that this is a good reason. Is this one of those things that was once true, but is no longer true? 2) If one instance of tomcat fails, the other can take over.

Downsides: There's more overhead when you have multiple versions and greater complexity.

If we need load balancing is it "better" to just put the second tomcat in another VM?

yalis
  • 1,508
  • 1
  • 16
  • 24

1 Answers1

2

If you have the option, a different VM would be prefered. You still get all the resource utilization benefits you mentioned of multiple JVMs. You ALSO get the redundancy of not having a single point of failure; your VM crashing will not bring down every node in a cluster.

If you HAVE to use one VM, the things to consider when using one tomcat instance vs. multiple are:

  1. Will the apps need different reboot/backup/ requirements? You don't want to be stuck on one instance and having to reboot it for one app when other apps should continue running.
  2. Will the apps running in tomcat need to talk to eachother directly (access object instances, config settings, etc.)? Remote communication is always a possibility (prefered) but I have seen WARs which were designed to talk with other WARs on the same tomcat instance.

The likely scenario is you would be bound by any of the above and you can do whatever you think works best for you. My preference would be in the following order:

  1. Separate VMs
  2. Same VM, same tomcat
  3. Same VM, different tomcats

2 & 3 in that order just because I don't want to have to manage more things than necessary. One tomcat is easier than 2 or more. But the best separation is at the server level.

Jesse Webb
  • 43,135
  • 27
  • 106
  • 143
  • How you propose to implement 3. (Same VM - different tomcats)? – FoxyBOA May 23 '12 at 07:14
  • @FoxyBOA - For 3 different apps, separate VMs would be prefered for the same reasons as above, e.g. they may have different deploy/reboot requirements, you don't want the deploy of one app to take down the other. But, if that is too hard/expensive, I would once again recommend using 1 VM with 1 Tomcat instance because it is less things to manage. The more apps you put on a single tomcat isntance though, the more you will have to load/performance test to ensure the single instance can handle the load on the system for all the apps. If the performance is unacceptable on one box, use more. – Jesse Webb May 23 '12 at 14:27
  • There is no 'right' answer to this problem, you have to try something and see if it suits your needs. If it doesn't make sure it is easy to change your mind later. – Jesse Webb May 23 '12 at 14:28
  • I see your points. I can't imagine how you propose to implement 3. Never head of anything like that. IMO VM == Tomcat. Am I wrong? – FoxyBOA May 23 '12 at 15:52
  • Often it is a good idea to have a single VM with many Tomcats, each using their own JVM which each run their own web-app. This allows you to do things like restart tomcat instances without affecting the others, have different configurations on each, or run each instance with different JVM args like giving one more memory. Using a single tomcat instance will seems simpler at first but will make it harder in the long run when one web-app's requirements change. Good luck. – Jesse Webb May 23 '12 at 17:55
  • Possible, never heard of such solution. Could you please point me out how could I configure single VM with many Tomcats? – FoxyBOA May 24 '12 at 07:57
  • 1
    You basically use different ports for each tomcat instance. Here is some apache documentation links explaining how/why you would do such a thing... 1: http://tomcat.apache.org/tomcat-3.2-doc/tomcat-apache-howto.html#multiple 2: http://tomcat.apache.org/tomcat-3.2-doc/tomcat-apache-howto.html#virtual_hosting You can also just Google for something like "running multiple tomcat instances" – Jesse Webb May 24 '12 at 14:15
  • Found an answer - http://stackoverflow.com/questions/1794444/use-multiple-catalina-base-to-setup-tomcat-6-instances-on-windows – FoxyBOA May 24 '12 at 14:27