来自同一会话的多个请求如何始终落在同一台服务器上?

How do multiple requests from same session always land on the same server?

来自同一浏览器会话的多个请求如何始终到达同一服务器?服务器负载平衡器是否使用来自多个请求的会话 ID 并重定向到同一服务器?

好吧,这取决于负载平衡器。他们中的大多数都支持这种功能(会话粘性)。

比如nginx (on the free version) supports ip_hash which redirects all the requests from the same ip to the backend server, and nginx plus supports additionally balancing based on session就是用cookie实现的。

Haproxy同样支持以上两种方式来实现负载均衡,同时也使用cookie来实现会话粘性。