Share Sessions between tomcat instances (without using Sticky Sessions)

后端 未结 4 1222
情话喂你
情话喂你 2021-02-01 05:28

I\'m going to have 3 Tomcat servers and a Load Balancer that dispatches the requests without using \'sticky sessions\'.

I want to share sessions\' data between the serve

4条回答
  •  既然无缘
    2021-02-01 06:15

    Persisting sessions in the database limits your scalability. If scalability is not that important for you this (db + memcached) is a valid approach.

    One thing you need to keep in mind when using nonsticky-sesions are concurrent requests: when you have e.g. ajax-requests (executed in parallel/concurrently) they will be served by different tomcats (due to non-stickyness) and therefore access the session concurrently. As long as you have concurrent requests that might modify the session you need to implement some kind of synchronization / session locking.

    Perhaps this is of interest for you: I created the memcached-session-manager with the goal of both optimal performance and unlimited scalability. It can work with any memcached-compatible backend (e.g. also memcachedb, membase etc. or just memcached). Although it was originally created for a sticky-sessions approach, there's already a branch for nonsticky-sessions existing and a sample app showing how/that it works. Right now there's a thread on the mailing list on further improvements for nonsticky-sessions (handling of concurrent requests and preventing single-point-of-failure).

提交回复
热议问题