As stated earlier in this chapter, you have two options for implementing a load-balancing mechanism for your Presentation tier :
Both options are discussed in detail in the following sections. Using a WebLogic Proxy Plug-in Load-Balancing SolutionThe WebLogic proxy plug-in is an ideal solution if you want to leverage an existing Web tier composed of Netscape, Microsoft, or Apache Web servers to proxy (forward) connection requests to the WebLogic cluster. Alternatively, you can also use WebLogic Server with the HttpClusterServlet as a proxy server. In a proxy server load-balancing scenario, when an HTTP client requests a servlet or JSP, the proxy plug-in or HttpClusterServlet proxies the request to a managed server in the WebLogic Server cluster. The accessed servlet or JSP maintains data on behalf of a connecting client by using a dedicated HttpSession object, which is created on a per-session basis. When the HTTP response is sent back to a client via the proxy server, the client's browser is instructed to write a cookie that lists the primary and secondary locations of the session's HttpSession object. Tip If the client's browser does not support cookies, the managed server can use URL rewriting instead to embed the primary and secondary locations of the HttpSession object into the URLs passed between the client and proxy servers. The primary location is the address of the managed server that received and processed the initial HTTP connection request. For subsequent HTTP requests, the proxy plug-in or HttpClusterServlet automatically maintains a "sticky" connection between the client and its primary HttpSession object location. The secondary location is the address of a managed server that maintains a replica of the HttpSession object that is used for in-memory session state failover purposes only; this object is discussed later in this chapter. Tip The HttpClusterServlet automatically maintains a list of managed servers in a WebLogic cluster, but you will have to configure this information manually and identically for each third-party Web server using the WebLogic proxy plug-in. The limitation for using a proxy server load-balancing solution is that you are currently constrained to using a round- robin strategy for distributing client requests to the managed servers in a WebLogic cluster. To showcase the load-balancing capabilities of the WebLogic proxy plug-in, as well as set up a WebLogic environment for subsequent examples in this chapter, the following section discusses how you can easily configure an HttpClusterServlet load-balancing solution. Configuring the HttpClusterServlet As a Load-Balancing SolutionBy default, the HttpClusterServlet is included with every WebLogic Server installation. However, for it to be able to function, the servlet must be deployed as the default application to WebLogic Server that will serve as the proxy server for a domain. Previously in this chapter, you configured the mycluster WebLogic cluster in your WebLogic domain. To demonstrate the load-balancing capabilities of the WebLogic proxy plug-in, you can deploy the HttpClusterServlet as the proxyApp default Web application on the administration server (AdminServer) of your WebLogic domain, which will serve as the proxy server, as illustrated in Figure 25.16. Figure 25.16. Load balancing the mycluster WebLogic cluster using the HttpClusterServlet .
Caution This configuration is used for demonstration purposes only. In a production environment, you should use a dedicated managed server as a proxy server and ensure the administration server is used only for administration tasks . Follow these steps to create and deploy the proxyApp Web application to the administration server of your WebLogic domain: Note If you use different names for your domain, administration server, and WebLogic cluster, substitute those names where appropriate.
After you deploy the proxyApp Web application, the next task is to specify that it is the default Web application on your proxy server. To do this, follow these steps:
As you can see in Figure 25.18, you can test the HttpClusterServlet by using the following URL in a Web browser, substituting the correct IP address or DNS name and port for your proxy server: http://EINSTEIN:7001/foo.jsp?__WebLogicBridgeConfig Figure 25.18. Testing the functionality of the HttpClusterServlet .
From this point onward, you can access applications deployed on your WebLogic cluster via a single entry point, your proxy server, using the following URL: http:// ip_address_of_proxy_server : port_of_proxy_server /< Application > Using a Hardware Appliance Load-Balancing SolutionIf you require a more sophisticated HTTP connection distribution strategy than just purely a round-robin approach, you should opt to use a hardware load-balancing appliance solution. In a load-balancing appliance scenario, when a client requests a servlet or JSP directly using an IP address, the load balancer routes the client's connection request to any available managed server in the WebLogic cluster in accordance with a selected load-balancing algorithm supported by the appliance. The managed server that receives the client request serves as the primary location of the client's HttpSession object. The secondary or replica HttpSession object is immediately created on another managed server. As a client initiates subsequent HTTP requests to the WebLogic cluster, the load-balancing appliance uses an identifier in the client-side cookie to ensure these requests are directed to the primary location of the client's HttpSession object. In its default configuration, WebLogic Server uses client-side cookies to keep track of the primary and secondary locations of the HttpSession object. Hence, to ensure a "sticky" connection between the client and its primary HttpSession object location using cookies, the load-balancing appliance must support a passive or active cookie persistence mechanism, as well as SSL persistence. If cookies are not supported by the client, as in the case of WAP-enabled devices, you must do the following:
Note If you decide to use URL rewriting, review BEA's e-docs for coding guidelines on how to programmatically handle URLs in your servlets and JSPs. |