• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

max no of Tomcat instance for load balance in a single server

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All, We wanted to load balance tomee(tomcat) server.I.e we want to make 2-3 separate tomcat instances and load balance with Apache.Can any once suggest max how many tomcat instance I can keep in a single server .
Server Details .
RAM: 16 GB
OS: W2008 R2
Processor: Intel(R) Xeon (R)2.70 GHZ
No of Cores: 4
We have single server now and we want to use that server only .So,I want to create max possible tomcat instance on single server.We don't want to buy new server to create more tomcat instance.
 
Saloon Keeper
Posts: 22482
151
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I thought Windows 2008 was supposed to be dead now.

You only have 4 cores, so the maximum number of Tomcat instances that could be processing simultaneously is 4.
 
Bartender
Posts: 1210
25
Android Python PHP C++ Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't see how multiple Tomcat processes on the same server can facilitate load balancing.
It's still the same machine with limited number of cores, limited RAM, and limited network bandwidth, but now with additional overheads of process switching and process memory.
AFAIK, tomcat has a thread pool based architecture, not an event loop. So a request serviced by 1 tomcat with a threadpool of 4n threads is the same as 4 tomcats with a total threadpool of 4n threads, and without the overheads.
Multiple tomcats on same server is not true horizontal scaling in my opinion.
 
Krishnam Ch
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Tim - Thanks
@Karthik :Thnaks . tomcat has a thread pool based architecture, not an event loop. So a request serviced by 1 tomcat with a threadpool of 4n threads is the same as 4 tomcats with a total threadpool of 4n threads, and without the overheads. .Are you saying here Should we increase thread pool on each instance .I am not much aware of tomcat architecture,setting.Can you elaborate or provide some reference url so that i can get more details.
Are you saying even if I create a extra instance (2nd tomcat instance ) ,it will increase performance/stability ?
 
Karthik Shiraly
Bartender
Posts: 1210
25
Android Python PHP C++ Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

load balance tomee(tomcat) server.I.e we want to make 2-3 separate tomcat instances and load balance with Apache. So,I want to create max possible tomcat instance on single server.We don't want to buy new server to create more tomcat instance.



I'll explain with an example scenario of what I mean.

You have 1 tomcat instance now.
Let's say you have set up CPU, memory and network performance monitoring on your server.
From your web server logs, you have found that you have a constant number of upto 500 or so concurrent requests.
From your perf monitoring, you've seen that one or more resources is overwhelmed.
It may be that CPU usage is uncomfortably high constantly (say > 80%).
Or memory usage is high (say > 80% of max heap), resulting in frequent garbage collections and increasing response delays.
Whatever it is, now you want to "load balance" to avoid overwhelming the server.

The correct way to load balance is to add more machines.
Earlier, you had 1 server with 4 cores and 16GB, and it was overwhelmed.
So you buy a second identical server and now you have totally 8 cores and 32GB.
Half the requests can now be distributed to the second machine, and that reduces the load on the first overwhelmed server.
This concept can be extended to any number of servers, because each one *adds* to your total CPU, memory, and network resource (strictly speaking, network bandwidth is still limited upstream, but until the upstream's limit is reached, it's still adding up).

But when you launch multiple tomcat instances on the *same* server, it's not adding anything to your total resources.
It's just making those resources even more scarce per instance.
If the single tomcat instance was overwhelmed earlier at 500 requests, each instance will become overwhelmed even earlier now
(maybe at 75 requests), because each one of them is competing with other instances for the same resources.

(2nd tomcat instance ) it will increase performance/stability ?


It won't increase performance.
But it can improve *availability* under standard loads.
If the single tomcat instance crashes due to some error, site visitors will get an error until it restarts.
But with additional instances, another instance can pick up the request immediately and respond.
But if the server itself crashes, it won't help with availability either, because all instances go down at the same time.

Are you saying here Should we increase thread pool on each instance


No, my point was to illustrate that adding more tomcat instances on same server is not going to balance CPU load, because there is no difference between 200 threads in 1 instance or 50 threads across 4 instances. From CPU point of view, it's still 200 threads and it still has only 4 cores to service them.

See Tomcat's Configuration guide and flow descriptions for understanding tomcat's use of threadpools.



 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic