7.5.2 Prefer local
Besides the server weighted round robin routing, WAS V6 provides another WLM routing policy: Prefer local.
This policy has a global scope for a given cluster. Once the Prefer local policy is turned on, it is applied for every cluster member in the cluster. Similarly, when you turn it off, it is off for every cluster member in your cluster.
With the Prefer local policy, the selection made by the WLM plug-in not only depends on the running cluster members and their weight, but also on the node where the request comes from. The WLM plug-in will only select cluster members on the same node as the client, unless all local cluster members are unavailable.
The advantage of the Prefer local policy is that there is no network communication between the client and the EJB, so depending on the chosen topology, this policy can significantly improve the overall performance.
The client is the Java virtual machine (JVM) in which the code calling the EJB is running. This client might be a WebSphere process such as an appserver running a Web container, or an appserver running an EJB container.
Prefer local results in the following behaviors:
- A servlet calls an EJB: the request goes to the EJB container running on the same system (node).
- EJB1 is calling EJB2: the request goes to the same EJB container if EJB2 can be found (Process affinity), or to another EJB container running on the same node.
- In the case of a Java program running on the same machine as WebSphere and using the WebSphere JRE and its ORB, the Prefer local policy will dispatch requests among EJB containers running on the same machine. EJB WLM requires the WebSphere ORB and its WLM plug-in. If non-WebSphere ORBs are used, then the Java client will not be able to participate in EJB WLM. The client accessing an EJB may also be a Java virtual machine not running in WebSphere, such as a J2EE client application, or a stand-alone Java program accessing EJBs. For a remote J2EE client application, the Prefer local policy has no influence on the request distribution because the client runs on a remote workstation.
If there is no cluster member available on the local system (because of a failure, or because of the topology), the request will be dispatched to available cluster members following the server weighted round robin routing policy, as described in 7.5.1, Server weighted round robin.
The selection of the Prefer local option should be based on topology and pre-production test results. Naturally, the local host call will be quicker, and if you can put your clients (usually Web containers) on the same machines as your servers, the Prefer local option is a good choice. If you have clients on a subset of your machines, then you should analyze the load distribution, since client requests come from remote machines as well as from the local machine.