Using IP hash load-balancing

The IP-hash-based session persistence cannot guarantee that user sessions are evenly distributed across servers. For example, there may be situations where a lot of user sessions are coming with the same IP address (behind proxies) and all these user sessions will go to the same server, which might cause unbalanced load. Therefore consider the impact carefully before you decide to go this way.

To configure Nginx as a load balancer and use the IP hash load-balancing method,

Step 1: Follow the sections below to install Nginx.

Step 2: Configure Nginx to direct requests to the PowerServer Web APIs group using the IP hash load-balancing method.

  1. Open the nginx.conf file in a text editor (nginx.conf is located in the ..\nginx-1.19.10\conf folder in Windows, or /etc/nginx/ in Linux).

  2. Under the "server" block that defines the virtual server, add another "server" block and "upstream" block that define the server group.

    • The "listen" directive specifies the port number for the requests. The Web API URL should point to this port number.

    • The "proxy_pass" directive forwards the request to the server group defined in the "upstream" directive, therefore, it should match with the upstream name.

    • The "upstream" directive defines the PowerServer Web APIs group.

      In the following example, the "upstream" block consists of three server configurations; it could consists of more.

      The "upstream" block also consists of the "ip_hash" directive which defines that the IP hash load-balancing method will be used when determining which server in the group the request will be directed to.

    The following configuration defines a PowerServer Web APIs group named webapi which consists of three .NET servers: https://172.16.100.34:6000/, https://172.16.100.35:6000/, and https://172.16.100.36:6000/, and requests made to the URL: https://<server>:8080/ will be redirected to the PowerServer Web APIs group.

        server {
            listen  8080;
            location / {
               proxy_set_header Host $http_host;
               proxy_pass https://webapi;
            }
        }
        upstream webapi{
            ip_hash;
            server https://172.16.100.34:6000;
            server https://172.16.100.35:6000;
            server https://172.16.100.36:6000;
            }