Distributed session

Several distributed session processing solutions summarized on the Internet are recorded here.

 

As we all know, services are generally divided into stateful and stateless, and distributed session is for stateful services.

Several Implementation Methods of Distributed Session
  • Database-based session sharing
  • Session replication mechanism based on resin/tomcat web container itself
  • Session sharing based on oscache/Redis/memcached.
  • Session sharing based on cookies
Several management methods of distributed session

  • Introduction to Session Replication mode management (ie session replication) : Broadcast and replicate session data on one machine to other machines in the cluster
    Usage scenario : Fewer machines and less network traffic
    Advantages : Simple implementation, less configuration, and when the network is running When a machine is Down, it does not affect user access.
    Disadvantages : When broadcast replication to other machines has a certain amount of time, it will bring a certain network overhead.


  • Introduction to session sticky management : that is, sticky session, when a user accesses a machine in the cluster, it is mandatory to specify that all subsequent requests fall on this machine.
    Usage scenario : moderate number of machines, not very strict requirements for stability
    Advantages : simple implementation, Easy configuration and no additional network overhead
    Disadvantages : When a machine in the network goes down, the user session will be lost, which is likely to cause a single point of failure


  • Introduction to centralized cache management : Store the session on a machine in the distributed cache cluster, and get the session information from the cache when users access different nodes.
    Usage scenario : There are many machines in the cluster and the network environment is complex .
    Advantages : reliability Disadvantages : complex implementation, stability depends on the stability of the cache, and a reasonable strategy for writing session information into the cache

currently used in production
  • MemCache cache management session implementation based on tomcat configuration (trouble)
  • Implementation based on OsCache and shiro multicast (network impact)
  • Based on spring-session+redis (most suitable)

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326316410&siteId=291194637