Skip Headers

Oracle® Application Server Containers for J2EE Enterprise JavaBeans Developer's Guide
10g Release 2 (10.1.2)
Part No. B15505-01
  Go To Documentation Library
Home
Go To Product List
Solution Area
Go To Table Of Contents
Contents
Go To Index
Index

Previous
Previous
Next
Next
 

Load Balancing Options

Load balancing for EJBs occurs across all OC4J processes included in the cluster.

The client retrieves a random OC4J process when the first lookup is executed. The selection of which OC4J process that services the client is always randomly chosen from among the pooled OC4J processes in the cluster. However, you can choose to have the client do the following:

If you are not interested in EJB state replication, but want to load balance your request among OC4J processes, the following sections describe your options:

Load Balancing Using Static Retrieval

If you decide to not use EJB replication, but you want to load balance the request across several OC4J processes, you can use static retrieval by providing the URLs for all of these processes in the JNDI URL property.

The JNDI addresses of all OC4J nodes that should be contacted for load balancing and failover are supplied in the lookup URL, and each address is separated by a comma. For example, the following URL definition provides the client container with three OC4J nodes to use for load balancing and failover.

java.naming.provider.url=ormi://s1:23791/ejbsamples, 
          ormi://s2:23793/ejbsamples, ormi://s3:23791/ejbsamples; 

DNS Load Balancing

Alternatively, if you do not want to use EJB replications, but you want to load balance the request using DNS for load balancing, you can do the following:

  1. Within DNS, map a single host name to several IP addresses. Each of the port numbers must be the same for each IP address. Set up the DNS server to return the addresses either in a round-robin or random fashion.

    The IP address identifies the OC4J running; the port number is an RMI port number.

  2. Turn off DNS caching on the client. For UNIX machines, you must turn off DNS caching as follows:

    1. Kill the NSCD daemon process on the client.

    2. Start the OC4J client with the -Dsun.net.inetaddr.ttl=0 option.

  3. Within each client, use ANY initial context factory to create an initial context. Use the ormi:// prefix in the provider URL. Use the single host name in the DNS server to which the OC4J IP addresses are mapped and the common RMI port in the provider URL for the client.

  4. Set the dedicated.rmicontext property to true.

Each time the lookup occurs on the DNS server, the DNS server hands back one of the many IP addresses that are mapped to it.

Example 13-1 RMIInitialContextFactory Example

This example uses an RMIInitialContextFactory object; however, you can use any initial context factory for DNS load balancing. In this example, myserver is the host name set up in the DNS server for the list of servers, and the RMI port is defaulting to the default port.

java.naming.factory.initial=
           com.evermind.server.rmi.RMIInitialContextFactory
java.naming.provider.url=ormi://myserver/applname
java.naming.security.principal=admin
java.naming.security.credentials=welcome
dedicated.rmicontext=true