Load Balancing Web Applications
Pages: 1, 2
Hardware Load Balancers
Hardware load balancers solve many of the problems faced by the round robin software solution through virtual IP addresses. The load balancer shows a single (virtual) IP address to the outside world, which maps to the addresses of each machine in the cluster. So, in a way, the load balancer exposes the IP address of the entire cluster to the world.
When a request comes to the load balancer, it rewrites the request's header to point to other machines in the cluster. If a machine is removed from the cluster, the request doesn't run the risk of hitting a dead server, since all of the machines in the cluster appear to have the same IP address. This address remains the same even if a node in the cluster is down. Moreover, cached DNS entries around the Internet aren't a problem. When a response is returned, the client sees it coming from the hardware load balancer machine. In other words, the client is dealing with a single machine, the hardware load balancer.
Server Load Balancing
Advantages of Hardware Load Balancers
Server affinity. The hardware load balancer reads the cookies or URL readings on each request made by the client. Based on this information, it can rewrite the header information and send the request to the appropriate node in the cluster, where its session is maintained.
Hardware load balancers can provide server affinity in HTTP communication, but not through a secure channel, such as HTTPS. In a secure channel, the messages are SSL-encrypted, and this prevents the load balancer from reading the session information.
High Availability Through Failover. Failover happens when one node in a cluster cannot process a request and redirects it to another. There are two types of failover:
- Request Level Failover. When one node in a cluster cannot process a request (often because it's down), it passes it along to another node.
- Transparent Session Failover. When an invocation fails, it's transparently routed to another node in the cluster to complete the execution.
Hardware load balancers provide request-level failover; when the load balancer detects that a particular node has gone down, it redirects all subsequent requests to that dead node to another active node in the cluster. However, any session information on the dead node will be lost when requests are redirected to a new node.
Transparent session failover requires execution knowledge for a single process in a node, since the hardware load balancer can only detect network-level problems, not errors. In the execution process of a single node, hardware load balancers do not provide transparent session failover. To achieve transparent session failover, the nodes in the cluster must collaborate among each other and have something like a shared memory area or a common database where all the session data is stored. Therefore, if a node in the cluster has a problem, a session can continue in another node.
- Metrics. Since all requests to a Web application must pass through the load-balancing system, the system can determine the number of active sessions, the number of active sessions connected in any instance, response times, peak load times, the number of sessions during peak load, the number of sessions during minimum load, and more. All this audit information is used to fine tune the entire system for optimal performance.
Disadvantages of Hardware Load Balancers
The drawbacks to the hardware route are the costs, the complexity of setting up, and the vulnerability to a single point of failure. Since all requests pass through a single hardware load balancer, the failure of that piece of hardware sinks the entire site.
Load Balancing HTTPS Requests
As mentioned above, it's difficult to load balance and maintain session information of requests that come in over HTTPS, as they're encrypted. The hardware load balancer cannot redirect requests based on the information in the header, cookies, or URL readings. There are two options to solve this problem:
- Web server proxies
- Hardware SSL decoders.
Implementing Web Server Proxies
A Web server proxy that sits in front of a cluster of Web servers takes all requests and decrypts them. Then it redirects them to the appropriate node, based on header information in the header, cookies, and URL readings.
The advantages of Web server proxies are that they offer a way to get server affinity for SSL-encrypted messages, without any extra hardware. But extensive SSL processing puts an extra load on the proxy.
Apache and Tomcat. In many serving systems, Apache and Tomcat servers work together to handle all HTTP requests. Apache handles the request for static pages (including HTML, JPEG, and GIF files), while Tomcat handles requests for dynamic pages (JSPs or servlets). Tomcat servers can also handle static pages, but in combined systems, they're usually set up to handle dynamic requests.
You can also configure Apache and Tomcat to handle HTTPS requests and to balance loads. To achieve this, you run multiple instances of Tomcat servers on one or more machines. If all of the Tomcat servers are running on one machine, they should be configured to listen on different ports. To implement load balancing, you create a special type of Tomcat instance, called a Tomcat Worker.
As shown in the illustration, the Apache Web server receives HTTP and HTTPS requests from clients. If the request is HTTPS, the Apache Web server decrypts the request and sends it to a Web server adapter, which in turn sends the request to the Tomcat Worker, which contains a load-balancing algorithm. Similar to the Web server proxy, this algorithm balances the load among Tomcat instances.
Hardware SSL Decoder
Finally, we should mention that there are hardware devices capable of decoding SSL requests. A complete description of them is beyond the scope of this article, but briefly, they sit in front of the hardware load balancer, allowing it to decrypt information in cookies, headers and URLs.
These hardware SSL decoders are faster than Web server proxies and are highly scalable. But as with most hardware solutions, they cost more and are complicated to set up and configure.
Vivek Viswanathan is an enterprise web application developer, whose interests include clustering, performance and optimization.
Return to ONJava.com.
Horizontal Clustering with Apache,Tomcat on Windows 2003 server
2009-08-02 23:42:56 prashant_net [View]
https load balancing with apache and mod_jk
2008-01-29 03:20:06 jim79 [View]
2007-10-17 23:31:31 thahari [View]
2007-10-17 23:28:40 thahari [View]
Load Balancing Experience
2007-10-04 06:21:43 bala2007 [View]
2007-09-16 01:05:49 abhim456] [View]
2007-09-10 23:32:12 Srinivas.A [View]
2007-05-25 03:56:46 kvenukumar [View]
tomcat 5.5.23 Creating hundreds of threads(java process) on linux
2007-05-30 14:27:41 unikideas [View]
2007-04-30 07:39:18 loadbalance [View]
2007-04-18 00:04:26 Rutvam [View]
2007-04-15 19:58:46 junren [View]
2007-02-14 02:24:34 loadbalancing [View]
2007-01-07 23:54:40 torala [View]
2006-10-26 22:14:46 suhaib [View]
How to get server Load information
2006-10-27 10:07:34 suhaib [View]
How to get server Load information
2007-09-10 23:41:39 Srinivas.A [View]
2006-08-29 09:32:26 HIO'Reilly [View]
2006-08-17 14:59:17 Mutyam [View]
2006-08-01 23:46:06 leads360 [View]
2006-07-26 04:24:30 CLUSTERING [View]
2006-06-27 22:48:46 RoboLab [View]
2006-06-27 22:45:08 RoboLab [View]
2006-04-28 16:54:02 hazad [View]
2006-02-25 10:36:15 email@example.com [View]
2005-08-22 07:21:53 trulore [View]
Load Balancing, Server Affinity, and HTTPS
2007-09-11 00:01:01 Srinivas.A [View]
Load Balancing, Server Affinity, and HTTPS
2007-03-26 15:02:38 rakesh1234 [View]
2005-05-26 03:39:46 Mohamed_Farouk [View]
2005-01-20 05:19:38 jasraj [View]
2008-12-30 04:29:43 Ponnusamy G [View]
2005-01-03 07:27:47 rboatwright [View]
2008-12-30 04:26:53 Ponnusamy G [View]
2007-09-11 00:09:13 Srinivas.A [View]
2004-12-23 23:16:58 Vikramk [View]
2004-12-13 23:59:54 HosamSaad [View]
2004-10-11 00:07:46 Acham_Sanjeev [View]
2004-09-08 20:49:37 [View]
2004-04-27 15:45:06 milovisho [View]
2004-01-22 23:02:20 viveksharma [View]
2003-12-14 04:24:43 anonymous2 [View]
2003-10-19 13:53:45 anonymous2 [View]
2003-09-15 15:38:56 anonymous2 [View]
2003-08-30 09:33:11 anonymous2 [View]
2003-08-26 01:16:41 anonymous2 [View]
load balnacing techniques for web server
2005-02-15 04:54:18 firstname.lastname@example.org [View]
2003-07-04 02:54:24 anonymous2 [View]
2003-04-29 00:05:57 anonymous2 [View]
2002-12-21 10:36:53 anonymous2 [View]
2002-11-29 10:48:27 anonymous2 [View]
2008-05-28 06:35:27 pbalhara [View]
2006-04-21 23:23:39 sameya [View]
2004-11-14 06:22:33 soudown [View]
2002-11-24 18:59:25 anonymous2 [View]
2002-11-11 22:19:43 anonymous2 [View]
2002-10-30 00:50:17 anonymous2 [View]
2002-09-23 21:12:54 anonymous2 [View]
2002-09-19 20:10:32 anonymous2 [View]
2006-10-12 06:39:00 gurukarthick [View]
2002-07-04 21:22:53 grkumar25 [View]
2002-05-03 02:19:55 kalyanasundarams [View]
2002-04-25 20:45:09 abhijit_khopkar [View]
2003-12-14 04:26:36 anonymous2 [View]
2001-12-30 07:22:06 hegandhi [View]
2001-12-20 03:12:05 sachinjoshi [View]
2001-11-16 17:00:47 dvsagar [View]
2001-10-06 19:59:23 hbr1 [View]
2001-10-03 18:12:15 bantsui [View]
2001-10-02 08:07:33 af48 [View]
2001-10-23 15:35:24 matthias63 [View]