Sometimes it is necessary to make the HTTP request executed on the particular server node of the J2EE instance and prevent ICM from load balancing the incoming request across running server nodes of the J2EE instance. For example, some tools deployed on AS Java of the SAP PI system are capable of collecting useful runtime information only from the server node on which they are run, and not from the whole cluster or at least all cluster nodes of the given J2EE instance (assuming there are at least two server nodes being configured and running on each of J2EE instances).
This kind of requirement can be easily achieved by minor enhancement of the constructed URL that is used when sending the HTTP request. Precisely speaking, we can use the parameter sap-nodeid with the value of the server node on which the request has to be executed, the parameter has to be specified at the end of the URL and has to be assigned the value of the valid server node identifier.
To demonstrate this behavior, let us sequentially send two HTTP requests to two different server nodes of the same J2EE instance of the SAP PO system. Core part of the URL (that is identical in both requests) is complemented with the mentioned parameter. In sake of better visibility of the described behavior, document cookies are displayed in the browser as well: IDs of the J2EE instance and its server node on which the request was actually executed are displayed there (see load balancing cookie SAPLB):
In order to use this functionality, it is necessary to:
- Enable supportability of the parameter sap-nodeid in ICM of the J2EE instance (profile parameter icm/HTTP/ASJava/enable_sap_nodeid needs to be set with value TRUE – by default, this parameter is not specified and the parameter sap-nodeid is ignored on the server side);
- Ensure that the HTTP request does not contain session ID (cookie JSESSIONID) – otherwise, the parameter sap-nodeid will be ignored on the server side. (in this demo, we used incognito mode in Google Chrome in order to achieve this).
Note: if the invalid server node identifier is specified in the parameter sap-nodeid, the HTTP request will not be redirected to running server nodes of the accessed J2EE instance – instead, the HTTP error 503 (“Service not available”) will be retured by ICM of the J2EE instance.
Attention: the described technique is not intended for common usage since it ignores J2EE instance internal load balancing principles using ICM and leads to uneven distribution of HTTP load across instance’s server nodes.
For additional information on this topic, check SAP Notes 1440724 (“Addressing server nodes directly in AS Java”) and 1894823 (“How to be balanced to one JAVA node directly”).