in my setup I use Nginx as reverse proxy and load balancer in front of IIS, using the hash directive.
For hash key I am using cookie which contains the customer ID - by this I am grouping the users (the connections) by the Customer they are currently working for. (The app has N-Customers, each customer has N-Users, each User can work for different Customers, but at single point of time it work for one Customer). By this I am having better IIS internal cache usages, as the users forwarded to same backend are using normally the same data. The problem with hash directive is that it cannot guarantee that the clients are good distributed between the backends.
So here my questions about the hash load balancing:
- can I somehow see, which hash on which backend is assigned?
- can I reset / recalculate the already assigned keys on base the daily app usage? seems that also on restart / reload the hashes are kept.
Here is my config:
upstream backend_web { hash $http_currentcustomerid; server 192.168.0.1:80 max_fails=1 fail_timeout=20s weight=9 ; server 192.168.0.2:80 max_fails=1 fail_timeout=20s weight=11 ; server 192.168.0.3:80 max_fails=1 fail_timeout=20s weight=4 ; }
Thanks for any help in advance.