Payara Server load balancing with NGINX

Uncategorized
No Image

NGINX Logo This short blog post will show you how to use NGINX to load balance between 2 or more Payara Server instances using the sticky session.

 

Requirements

The sticky session directive is included in the commercial release of nginx only, for this reason we are using the nginx-sticky-module-ng (not officially supported) module:
https://bitbucket.org/nginx-goodies/nginx-sticky-module-ng
There are some minimal syntax differences between this and the commercial module, the latter gives more flexibility and more configuration options.

Architecture:

NGNX

Configuration:

nginx.conf
http {
upstream backend {
           sticky domain=.mydomain.com path=/ expires=1h httponly;
           server 192.168.0.3:28080;
           server 192.168.0.4:28080;
}
server {
               location / {
                   proxy_pass http://backend;
               }
}
}

In the http block we add the list of our servers, and the sticky directive used to configure the cookie creation options. It’s possible to define the name of the cookie (by default is ‘route’), but if you use the JSESSIONID name it will conflict with the cookie created by the JAVA application servers behind. 

In the server block we define which location (in our case the root /) should be proxied to the backed servers previously defined.
In case we have more nginx frontend servers, and a load balancer in front of, we can apply the same configuration to nginx, and configure the load balancer stickiness using the cookie name defined.

 

 

Comments (1)

Post a comment

Your email address will not be published. Required fields are marked *

Payara needs the contact information you provide to us to contact you about our products and services. You may unsubscribe from these communications at any time. For information on how to unsubscribe, as well as our privacy practices and commitment to protecting your privacy, please review our Legal & Privacy Policy.

  1. Michael Remijan

    Payara blog is awesome!

Related Posts

6 minutes
Uncategorized

Conf42 IoT 2024: At the Edge of Robotic Applications

At the latest Conf42 Internet of Things (IoT) 2024 conference, our Payarans deliver a keynote, titled “At the Edge […]

5 minutes
Uncategorized

10 Reasons Why Java is the Future of Enterprise App Development in 2025

Java has been a core element of enterprise application development for decades, and its relevance will continue to grow […]

5 minutes
Uncategorized

Keen To Slash Software Development Costs? Here’s What To Look For In A Middleware Solution

For technology companies, cost effectiveness in software and application development isn’t just about saving money. It is about delivering […]