witsches
witsches

Reputation: 227

about ip_hash in nginx upstream module

I want to replace pound with nginx as loadbalancer and all tests look fine so far. I will do a typical upstream configuration like this:

upstream backend {
  ip_hash;
  server   backend1.example.com;
  server   backend2.example.com;
  server   backend3.example.com;
}

There are now 2 questions left open:

  1. How long does this stickyness last? Is there a ttl to be defined somewhere?
  2. Does the stickyness survive restarts and/or reloads of nginx?

I could not find the answer in the nginx wiki. Links to official docs are welcome.

Upvotes: 9

Views: 21151

Answers (2)

arbitrary_A
arbitrary_A

Reputation: 373

It comes up when you do feel for need of session persistency. Scenario is like the users should be directed to same server as application demands based on previous connection.

ip_hash = key-value pair hashing [where key=visitor's ip, value=host server]

Upvotes: 1

Sergey Budnevitch
Sergey Budnevitch

Reputation: 146

It is based on client source ip address hash and as long as you have same set of backends stickiness will persist.

http://nginx.org/en/docs/http/ngx_http_upstream_module.html#ip_hash

Upvotes: 13

Related Questions