Use of nginx-sticky-module (cookie-based session persistence)

In the environment of multiple background servers, in order to ensure that a client communicates with only one server, we are bound to use a long connection. What method is used to achieve this connection? It is common to use the ip_hash that comes with nginx . I think this is definitely not a good method. If the front end is a CDN, or a LAN client accesses the server at the same time, the server will appear. The distribution is uneven, and there is no guarantee that every visit will stick to the same server. If it is based on cookies, think about it, each computer will have different cookies, while maintaining a long connection, it also ensures the pressure balance of the server, nginx sticky is recommended.

If the browser does not support cookies, sticky will not take effect. After all, the entire module is implemented for cookies.

nginx sticky other syntax

sticky [name=route] [domain=.foo.bar] [path=/] [expires=1h] [hash=index|md5|sha1] [no_fallback];
name: can be any string character, the default is route
domain: which domains can use this cookie
path: which path pairs enable sticky, such as path/test, then only the test directory will use sticky for load balancing
expires: cookie expiration time, which expires when the browser is closed by default, that is, the session mode.
no_fallbackup: If this is set and the server corresponding to the cookie is down, 502 (bad gateway or proxy error) will be returned. It is recommended not to enable it

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326940160&siteId=291194637