Welcome! Log In Create A New Profile

Advanced

Nginx 3rd party sticky module with backup server

Posted by rits 
Nginx 3rd party sticky module with backup server
December 14, 2015 03:54AM
Hi,

I want to use nginx 3rd party sticky module in opensource nginx, but I also need to configure a backup server. Nginx sticky module does not allow backup directive.
Is there any alternate way to configure a backup server along with using sticky module?

Thanks.
Re: Nginx 3rd party sticky module with backup server
December 14, 2015 04:29AM
With Lua just about anything is possible in this scenario, but the question should be:

what are you going to do with sticky session data when it falls over?

Stickiness is used to maintain and be consistent for one data session and its backend processor, a backup server may very well not know what to do with a session it knows nothing about or may even process the wrong data...

I'd suggest using Lua to perform health checks on your Sticky pool AND all active sticky sessions to each pool member, once a member is down you must expire all sticky sessions and maybe even do a rollback on sticky database sessions or implement a post completion mechanism.

The use of Sticky is explicit in its purpose and come with a few digital health warnings.

---
nginx for Windows http://nginx-win.ecsds.eu/



Edited 1 time(s). Last edit at 12/14/2015 04:30AM by itpp2012.
Re: Nginx 3rd party sticky module with backup server
December 14, 2015 05:49AM
Thank you for your response. I am new to nginx, can you elaborate or send a link to using Lua with nginx sticky module(for windows).
I need back up option so that in case 1 server becomes unavailable, all subsequest new requests go to available servers. My upstream application already handles unavailable sessions.

Also, is it possible to use the generic hashing to send all requests to same server for stickiness, using my upstream address?


upstream myLoadBalancer {
hash $upstream_addr;
server remote1:port1;
server remote1:port2;
server remote2.:port1;
}
Is something like above possible?
Re: Nginx 3rd party sticky module with backup server
December 14, 2015 06:09AM
rits Wrote:
-------------------------------------------------------
> Thank you for your response. I am new to nginx, can you elaborate or
> send a link to using Lua with nginx sticky module(for windows).

See our manual "NGINX for Windows - The Latest Documentation" at http://nginx-win.ecsds.eu/ chapter 18.
Adding Lua for upstream checks: https://github.com/openresty/lua-resty-upstream-healthcheck

> I need back up option so that in case 1 server becomes unavailable,
> all subsequest new requests go to available servers. My upstream
> application already handles unavailable sessions.

Then leave the upstream as it is, when a member is down nginx will mark it as such (down), ea. refrain from using 'backup'.

> Also, is it possible to use the generic hashing to send all requests
> to same server for stickiness, using my upstream address?
>
> upstream myLoadBalancer {
> hash $upstream_addr;
> server remote1:port1;
> server remote1:port2;
> server remote2.:port1;
> }
> Is something like above possible?

Should be possible, the only way to know is to test this to make sure the 'client' really is 'stuck' to the same member.

---
nginx for Windows http://nginx-win.ecsds.eu/
Re: Nginx 3rd party sticky module with backup server
December 14, 2015 06:22AM
Thanks.

I tried it. sessions are sticking to the same server but It is not doing round robin, My all requests are going only to first upstream server configured in nginx config.

How will nginx know next sequence of requests should go to next server and stick.


Sticky module does it with co0okie, Don't see that edeciding parameter when using upstream address as hashing. Any inputs on this?
Re: Nginx 3rd party sticky module with backup server
December 14, 2015 06:52AM
rits Wrote:
-------------------------------------------------------
> Thanks.
>
> I tried it. sessions are sticking to the same server but It is not
> doing round robin, My all requests are going only to first upstream
> server configured in nginx config.

Round robin and sticking to one member do NOT go together (unless a member has failed).

ea. you want to go from A to B and have to choose between a tunnel and a bridge, you can't use both.

Sticky sticks to the first available member and any subsequent call is routed via the cookie to the same member, ip_hash is what comes the closest to what sticky does.

---
nginx for Windows http://nginx-win.ecsds.eu/
Re: Nginx 3rd party sticky module with backup server
December 14, 2015 07:26AM
True, You are right.

The issue I am facing is

upstream myLoadBalancer {
> hash $upstream_addr;
> server remote1:port1;
> server remote1:port2;
> server remote2.:port1;
> }

say first server is selected from upstream. Since I have specified hash $upstream_addr, all subsequent requests go to this server. Even new requests. There is no new cookie or parameter to change it to next server for new set of stateful requests.

I think that is how generic hash works(not cookie based), dependiong on either request IP, request parameter, it sticks to a backend server.

So looks like not ideal in my scenario.

For Lua: https://github.com/openresty/lua-resty-upstream-healthcheck,

Is it available in nginx version 1.9, or it requires adding another module?
Re: Nginx 3rd party sticky module with backup server
December 14, 2015 07:59AM
rits Wrote:
-------------------------------------------------------
> say first server is selected from upstream. Since I have specified
> hash $upstream_addr, all subsequent requests go to this server. Even
> new requests. There is no new cookie or parameter to change it to next
> server for new set of stateful requests.

Thats just how it works without using a cookie to route, it would be the same if you would create a token with Lua.
You may have a bigger problem when using another upstream server in front of nginx since all IP's would be coming from this 'frontend' server and not its users. (which is the reason why Sticky came to life)

> I think that is how generic hash works(not cookie based), dependiong
> on either request IP, request parameter, it sticks to a backend
> server.

Without sticky its pure IP based, sticky is an end-2-end solution no matter how many hubs are in between.

> For Lua: https://github.com/openresty/lua-resty-upstream-healthcheck,
>
> Is it available in nginx version 1.9, or it requires adding another
> module?

Search for openresty which also has a development Windows version with the same restrictions as the original nginx Windows has. (what we produce is NOT related to nginx products coming from nginx themselves)

---
nginx for Windows http://nginx-win.ecsds.eu/
Re: Nginx 3rd party sticky module with backup server
December 14, 2015 10:20AM
Thanks for inputs. Really appreciate.

Does sticky module work with SSL on, for https requests? Has anyone tried?
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 147
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready