Show TOC Start of Content Area

Function documentation Load Balancing of Client RMI-P4 Requests  Locate the document in its SAP Library structure

Use

Client RMI-P4 requests are load balanced at the point where the client creates an InitialContext and obtains a reference to the remote server-side object using it. This reference contains information about the element ID of the server process where the remote object resides. That guarantees that subsequent client requests are sent to the same server process where the remote object is actually created.

In a Web AS cluster with several Java instances, you have two options for load balancing client RMI-P4 requests:

      Request a particular Java instance and have the request dispatched to any of the server processes within it

      Use the Message Server to retrieve the list of available Java instances.

To select any of the two options, you provide specific parameters in your remote client code when creating the InitialContext.

Features

Request a Particular Java Instance

To send a request to a particular Java instance, you provide the host and P4 port of the Java dispatcher for this instance as a value to the PROVIDER_URL property for the InitialContext in your remote client code:

Syntax

Properties p = new Properties();

p.put(Context.INITIAL_CONTEXT_FACTORY, "com.sap.engine.services.jndi.InitialContextFactoryImpl");

p.put(Context.PROVIDER_URL, "p4://<host>:<P4_port>");

p.put(Context.SECURITY_PRINCIPAL, "<user>");

p.put(Context.SECURITY_CREDENTIALS, "<password>");

ctx = new InitialContext(p);

 

The ICM  then uses the round robin algorithm to select the server process within this instance that should process the request. The remote object is created on this server process and the client communicates with the object using the obtained reference to it.

Note that this scenario provides a lower level of fault tolerance for your RMI-P4 application. If the Java instance is lost because the host it runs on had a hardware crash, then communication between your client and the remote object is impossible until the instance is brought back online.

Consider using the next scenario if you need a higher level of fault tolerance for your RMI-P4 application.

Use of the Message Server for Load Balancing Between Java Instances

You can use the Message Server for load balancing requests coming from your RMI-P4 client. To do this, you provide the Message Server’s host and port as a value to PROVIDER_URL property for the InitialContext in your remote client code:

Syntax

Properties p = new Properties();

p.put(Context.INITIAL_CONTEXT_FACTORY, "com.sap.engine.services.jndi.InitialContextFactoryImpl");

p.put(Context.PROVIDER_URL, "ms://<msgserver_host>:<msgserver_HTTP_port>/P4");

p.put(Context.SECURITY_PRINCIPAL, "<username>");

p.put(Context.SECURITY_CREDENTIALS, "<password>");

ctx = new InitialContext(p);

Note

You can obtain the Message Server’s HTTP port from the instance profile. By default, it is 81<xx> where <xx> stands for the instance number.

This way the client retrieves the list of available Java instances. Using the weighted round robin algorithm, it selects an instance and connects to the corresponding Java dispatcher. The ICM then load balances the request to a server process within the same instance using the round robin algorithm. The remote object is created on this server process and the client communicates with the object using the obtained reference to it.

Connecting to the remote object using the Message Server provides higher availability of your application, even if the host running the corresponding Java instance crashes. In this case, the RMI-P4 client can connect to another available instance and obtain a new InitialContext there.

End of Content Area