Tomcat Clustering


Published on

Published in: Technology
No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Tomcat Clustering

  1. 1. Tomcat Clustering GouthamV Sr.Software Engineer InfoGroup
  2. 2. Tomcat Clustering <ul><li>Why Clustering? </li></ul><ul><li>Tomcat Clustering Model </li></ul><ul><li>Load Balancing types </li></ul><ul><li>State/Session sharing types </li></ul><ul><li>Example cluster </li></ul><ul><li>Configuration steps </li></ul>
  3. 3. Why Clustering? <ul><li>Cluster: </li></ul><ul><li>Group of application servers that transparently run a J2EE application </li></ul><ul><li>as if it were a single entity </li></ul><ul><li>Enterprise applications must provide Scalability and High </li></ul><ul><li>Availability(HA) for web services in order to serve hundreds/thousands </li></ul><ul><li>of users. </li></ul><ul><li>Scalability: </li></ul><ul><li>System’s ability to support increasing number of users by adding </li></ul><ul><li>additional servers to cluster </li></ul><ul><li>High Availability(HA): </li></ul><ul><li>Providing redundancy in the system, if one cluster member crashes for </li></ul><ul><li>some reason, another member in the cluster can transparently take over </li></ul><ul><li>the web requests. </li></ul>
  4. 4. Cluster Types <ul><li>Two types of clustering methods: Vertical Scaling and Horizontal Scaling </li></ul><ul><li>1. Vertical Scaling: </li></ul><ul><li>Multiple number of servers running in single machine. </li></ul><ul><li>Ex: Server entapp4. Request can be served by any Tomkerb instance transparently </li></ul>TomkerbA TomkerbB TomkerbC
  5. 5. Cluster Types <ul><li>Two types of clustering methods: Vertical Scaling and Horizontal Scaling </li></ul><ul><li>1. Horizontal Scaling: </li></ul><ul><li>Independent servers running in different machines. Request can be served by any </li></ul><ul><li>machine transparently. This is recommended strategy in production environment </li></ul><ul><li>Ex: entapp4A entapp4B entapp4C </li></ul>Tomkerb Tomkerb Tomkerb
  6. 6. Tomcat Clustering Model Load Balancing Front-end (many choices of technology) Tomcat server instance 1 Tomcat server instance 2 Tomcat server instance N State/Session Sharing Back-end (many choices of technology) Incoming requests
  7. 7. Tomcat Load Balancing Apache ---------------- mod_jk2 Incoming requests Coyote AJP ---------------- Tomcat1 Overloaded Tomcat server Apache ---------------- mod_jk2 Incoming requests Coyote AJP ---------------- Tomcat2 Coyote AJP ---------------- Tomcat3 Coyote AJP ---------------- Tomcat1 Load balanced cluster Mod_jk2: Apache module provides integration between Apache web server and Tomcat. Coyote AJP: Provides communication channel between Apache and the running instances of Tomcat.
  8. 8. Load Balancing Types <ul><li>Round-robin DNS, whereby a domain name resolution results in a set of IP addresses </li></ul><ul><li>A hardware-based load balancer </li></ul><ul><li>A software-based load balancer (For ex: balance, an open source project) </li></ul><ul><li>The balancer web application included with Tomcat5 for rule-based, application-level load </li></ul><ul><li>balancing </li></ul><ul><li>Apache mod_jk2 as load balancer (Commonly used type) </li></ul>
  9. 9. State/Session Sharing Types <ul><li>Sticky sessions with no session sharing: </li></ul><ul><li>- Easy to configure, no changes needed to the existing applications. If server crashes </li></ul><ul><li>session is lost </li></ul><ul><li>- Application scalability through round-robin load balancing. </li></ul><ul><li>Sticky session with a Persistent Session Manager and a shared file restore </li></ul><ul><li>Sticky session with a Persistent Session Manager and a JDBC store to RDBMS </li></ul><ul><li>In-memory session replication </li></ul><ul><li>- These above three require complex configuration and existing applications have to be modified(All session objects should implement Serializable interface, etc) </li></ul><ul><li>Sticky session: Apache feature, when enabled on mod_jk2, it ensures all incoming requests with same session are routed to the same Tomcat 5 worker. </li></ul>
  10. 10. Configuration steps <ul><li>Create two tomcat instances </li></ul><ul><li>Modify server.xml in two instances for Server port, Connector port, AJP/1.3 port (Not required for horizontal scaling) </li></ul><ul><li>Modify of apache web server to define list of workers </li></ul><ul><li>Modify httpd.conf of apache web server to define balance as worker </li></ul><ul><li>If session sharing required, uncomment <Cluster> tag in server.xml of tomcat workers </li></ul><ul><li>and change TcpListenPort. </li></ul>