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

Tomcat Clustering

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