Lesson Overview
An SAP system can be scaled using the number of application servers and the number of dialog work processes (ABAP) or server processes (Java) for each instance. Requests to the SAP system should be distributed as equally as possible across all application servers and processes. A load balancing procedure is required to do this. The techniques used for this in the SAP system are introduced in this lesson.
Lesson Objectives
After completing this lesson, you will be able to:
• Explain how load balancing can be realized in the SAP system
Business Example
With large applications, it is best to spread the load across several components.
Load balancing is also possible with SAP NetWeaver AS Java.
Overview
In this section, the different mechanisms for load balancing that are available for SAP NetWeaver AS are presented. You can essentially differentiate between two mechanisms for load balancing: Client-based and server-based load balancing. In general, we recommend server-based load balancing.
Server-Based Load Balancing
A load balancer connected in front acts as a central entry point to the SAP system.
This is the case, even if the SAP system is made up of multiple application servers.
These technique offers the following advantages:
• All application servers can be addressed using a common IP address or a common name.
• The users always use the same URL to access the system.
• The advantages listed above reduce the operating and maintenance effort and costs.
This central entry point to the SAP system can be realized using an additional component, known as a “load balancer”. As shown in the following figure, this load balancer receives inbound requests and distributes these to the application servers.
Figure 28: Server-Based Load Balancing
Client-Based Load Balancing
In addition to SAP's preferred method of server-based load balancing, there are other methods, which can be preferred in certain circumstances. In particular, if a simple implementation of load balancing is desired. With this client-based load balancing, all inbound client requests are initially directed to a central location in the system, a load balancing server, when the connection is first made. The load balancing server informs the client which application server it should address.
This is illustrated by the following figure.
Figure 29: Client-Based Load Balancing
Client-based load balancing can be realized using the following mechanisms:
Rerouting the requests using functions
-• That provide the HTTP protocol (redirect)
• That provide the Domain Name System (DNS) protocol, with which the namespace in the Internet is managed
A simple method of load balancing is already implemented in SAP NetWeaver AS, based on the rerouting of HTTP requests. Their function is shown in the following figure.
Figure 30: Load Balancing Using the SAP Message Server
This mechanism functions as follows:
1. The browser sends a request to the message server.
2. The message server returns the address of an appropriate application server to the browser (redirect).
3. The browser now sends a request to this application server.
4. The user remains connected to this application server for the rest of the duration of the session.
Although this method is implemented in SAP NetWeaver AS using the message server (for AS ABAP or AS ABAP and Java System, this is the ABAP Message Server; for AS Java, this is the Java Message Server), and is already available after installation, it is not the preferred method due to a number of disadvantages. Some of these disadvantages are listed briefly here:
• Can lead to confusion of the user, since the URL displayed in the browser changes with the rerouting
• If Favorites are created in the browser, these point to the server to which the user was rerouted
• Can cause problems if a firewall is used Stateless and Stateful Web Applications
The programming model that underlies the development of Web applications has an important influence on a load balancer. The programming model differentiates between “stateless” and “stateful” Web applications.
The programming model for stateless requests is used for simple applications, for which each request to SAP NetWeaver AS is independent of all other requests.
The programming model for stateful requests is used for more complex
applications, which are based on a transactional concept. With these applications, information about the status of the user session must be stored in the application server.
The mechanism for load balancing in the SAP system must support both stateless and stateful requests. Stateful requests are a particular challenge for the load balancer, since the HTTP protocol only supports stateless requests. This is illustrated in the following figure. The first request is forwarded to an application server by the load balancer. If a subsequent request is forwarded to a different application server, this has no information about the user context.
Figure 31: Stateful Requests
The load balancer must therefore ensure that stateful requests are always forwarded to the same application server. This can be achieved by different implementations in the load balancer. However, these different techniques are not presented in more detail here.