Difference between session affinity and sticky session?

后端 未结 7 1393
伪装坚强ぢ
伪装坚强ぢ 2020-12-04 05:41

What is the difference between session affinity and sticky session in context of load balancing servers?

7条回答
  •  情歌与酒
    2020-12-04 06:06

    I've seen those terms used interchangeably, but there are different ways of implementing it:

    1. Send a cookie on the first response and then look for it on subsequent ones. The cookie says which real server to send to.
      Bad if you have to support cookie-less browsers
    2. Partition based on the requester's IP address.
      Bad if it isn't static or if many come in through the same proxy.
    3. If you authenticate users, partition based on user name (it has to be an HTTP supported authentication mode to do this).
    4. Don't require state.
      Let clients hit any server (send state to the client and have them send it back)
      This is not a sticky session, it's a way to avoid having to do it.

    I would suspect that sticky might refer to the cookie way, and that affinity might refer to #2 and #3 in some contexts, but that's not how I have seen it used (or use it myself)

提交回复
热议问题