Adding to what Dipak Chopade said, the routing depends on type of load balancing you have in place. Options available are
- HTTP Based Load Balacing
- mod_jk based load balancing (if use use Apache as a load balancer between multiple hosts)
For HTTP based load balancing, the load balancer just acts as a proxy and traffic manager. It receives http connections and route it to apache web server present in each of the nodes. It can also help in
- Heartbeat check through health check URLs to ensure that it routes to a node which is active
- Network traffic based load balancing ensuring the load is evenly distributed between nodes
- HTTPS offloading - if you are using SSL
- and so on
Selection of host to route the first connection request from a client is made by the loadbalancer based on the kind of load balancing algorithm, (predictive, fastest , dynamic round robin and so on).Apache front end on each of the nodes performs a mod_jk based routing to method servers present in each node (if you have multiple method servers in each of the slave nodes). Session affinity should be enabled on load balancer to ensure that the first to last transactions from a particular browser session is routed to the same host. Apache in each node makes use of jsessionid to make sure that the transaction reaches the right method server.
mod_jk based load balancing uses the same logic which Apache uses to route request to method servers in a host that has multiple method servers. Apache is commonly used as mod_jk load balancer to route request to embedded tomcats in each of the method servers in slave nodes. I have not seen any production installation with this configuration. More details can be found in https://support.ptc.com/appserver/cs/view/solution.jsp?n=CS40808
Thank you
Binesh Kumar