• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Load Balance Multiple Tomcats on Same Server

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can I loadbalance multiple tomcat servers on the same machine? I've got a big server with tons of RAM and have installed Apache as a loadbalancer for the different instance of tomcat. I know I can install multiple tomcat servers and just change the inbound port that they use, but I want to make sure I can load balance the clients coming in and take advantage of as much of the memory as possible.
 
Ranch Hand
Posts: 344
Oracle Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If it's on the same machine, how does load balancing help? Can't you just increase the heap space used by the JVM in your tomcat startup script?
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, that's possible - my shop does that. There are advantages to being able to take down servers independently without bringing down the entire site.
 
Rancher
Posts: 2759
32
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can configure apache to load balance between the Tomcats using mod proxy balancer.

You didn;t mention if you are replicating the session between tomcats. If you aren't make sure you configure the load balancer to be in sticky mode.
 
Jayesh A Lalwani
Rancher
Posts: 2759
32
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Koen Aerts wrote:If it's on the same machine, how does load balancing help? Can't you just increase the heap space used by the JVM in your tomcat startup script?



It's going to be more than just increasing the memory size. Default Tomcat configuration is tuned to handle medium loads. If you want Tomcat to handle large loads you have to tune various resource pools. For example, you need to make sure your database connection pool and connector thread pool is larger. I haven't personally tuned Tomcat to handle large loads, but google for it, you find several blogs/white papers on the subject.
 
Koen Aerts
Ranch Hand
Posts: 344
Oracle Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jayesh A Lalwani wrote:

Koen Aerts wrote:If it's on the same machine, how does load balancing help? Can't you just increase the heap space used by the JVM in your tomcat startup script?



It's going to be more than just increasing the memory size. Default Tomcat configuration is tuned to handle medium loads. If you want Tomcat to handle large loads you have to tune various resource pools. For example, you need to make sure your database connection pool and connector thread pool is larger. I haven't personally tuned Tomcat to handle large loads, but google for it, you find several blogs/white papers on the subject.


I understand all that, including benefits to load balancing, it's just that the original question didn't provide much context as to why multiple instances were needed and it only mentioned to use as much memory as possible. So I figured, if it's only about using more memory, then I'm not sure adding more tomcat instances is the right answer.
 
Mitch Walker
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The way I understand it each instance of tomcat uses its own JVM. Since I can assign about 2gb of ram for each JVM the hardware ive got really doesn't get used. ULf - what did your worker.properties file end up looking like?
 
Jayesh A Lalwani
Rancher
Posts: 2759
32
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you using 32 bit or 64 bit Java? 32 bit Java processes are constrained to 2GB, but 64 bit Java can grow much larger.. more than the actual RAM you have.
 
Mitch Walker
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's a 64-bit os and I thought java had installed the correct version, but that needs to be checked now that you mention it.
 
Jayesh A Lalwani
Rancher
Posts: 2759
32
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If it's 64 bit Java, you can increase the heap size by changing the -Xmx option
 
Bras cause cancer. And tiny ads:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic