0

I'm installing Railo on an AWS EC2 (Ubuntu) instance. I came across this guide for installing Railo on Ubuntu with multiple Tomcat7 instances, which prompts the following question:

Given the ability to "spin up" multiple EC2 instances and load balance with elastic IP/Route 53, does configuring each individual EC2 instance to run multiple Tomcat instances provide additional benefit? Is it worth it, or is it just redundant?

Jeromy French
  • 11,812
  • 19
  • 76
  • 129
  • I suspect with tomcat you wont need to. The main reasons for running a number of threads is to take advantage of multiple cores with single threaded applications and to provide listeners when other threads might be blocked by io. – datasage Mar 11 '13 at 02:01

2 Answers2

2

You'll have to identify your bottlenecks: If your server is running out of memory with a single tomcat, there's no use in starting a second tomcat. Also, if your CPU is maxed out, there's typically no advantage in spining up a second tomcat.

However, if you're balancing between different servers anyway, have enough CPU and memory available on one machine, you might gain something from running two tomcats on one machine: E.g. you can remove one of them at a time from the loadbalancer, update it and add it to the balancer again - then do the same for the second one.

But... you can do this with one tomcat per VM anyway.

I'm afraid: You'll have to answer this question to yourself, by measuring: If the load that you get can be handled by 4 tomcats on 4 EC2 instances, can it also be handled by 4 tomcats on 2 EC2 instances? How many resources (CPU, memory, I/O) do you typically have free on each of the EC2 instances you run? This all is heavily dependent on your usecase and what the machines are actually doing.

More examples: If your network bandwidth is saturated while you have CPU and memory left, a second tomcat will not leverage more bandwidth on the machine - it will only lower the throughput on the other tomcat as they'll have to share the connection bandwidth.

If your network bandwidth is not saturated and your tomcat is waiting for external resources (e.g. webservices, databases) it might make sense to utilize surplus CPU and Memory with a second instance.

But then there's the point of resilience: If one EC2 instance goes down, it would take two of your tomcats with it. Can you tolerate that or is that the point why you went to the cloud in the first place?

Olaf Kock
  • 46,930
  • 8
  • 59
  • 90
  • To clarify: "no use in starting a second"..."no need to spin up a second"--both those statements refer to a second *Tomcat*, and not a second EC2 instance, right? – Jeromy French Jul 05 '13 at 23:14
1

Adding to Olaf's answer, it depends on your requirements for fault tolerance and cost for a couple of reasons. I remember reading an article stating that a larger instance is cheaper than several smaller instances with the same capacity, I don't recall the URL but it's easy to do the math.

Amazon instances should not be treated as permanent and the host machine can go down at any time, taking all the VMs with it, including yours. Thus you will lose all Tomcat instances in that EC2 instance. Of course, you can provision enough so the loss is not a problem, but here's where you know your app.

But there's something else: with multiple Tomcat instances on the same machine, you have to manage the ports they are listening to so there is no collision. And to configure the Elastic Load Balancer so that is uses all of them. Doable, but a bit messier than having multiple EC2 instances listening on the same port.

wishihadabettername
  • 14,231
  • 21
  • 68
  • 85