问题的产生
An important issue when operating a load-balanced service is how to handle information that must be kept across the multiple requests in a user’s session. If this information is stored locally on one backend server, then subsequent requests going to different backend servers would not be able to find it. This might be cached information that can be recomputed, in which case load-balancing a request to a different backend server just introduces a performance issue.
解决方案
- ip 相同则转发到相同的 backend server(nginx: ip_hash)
问题1:ISP 的 ip 可能是动态变化的。
问题2:同一局域网下出口 ip 都是同一个,如果该 ip 访问量巨大,会导致负载均衡失效。 - session 数据相同则转发到相同的 backend server(nginx: hash)
One basic solution to the session data issue is to send all requests in a user session consistently to the same backend server. This is known as persistence or stickiness. A significa