ITPub博客

首页 > 架构设计 > 基础设施 > Solutions for Session Consistency Problem in Web Cluster

Solutions for Session Consistency Problem in Web Cluster

原创 基础设施 作者:eurt 时间:2019-04-15 23:15:53 0 删除 编辑

How to keep a session consistent across Web cluster?

Sol 1: ip_hash based load balance

The load balancing strategy of nginx can be configured to ip_hash.
The basic idea is Hash(client_ip)%nodes.
Sol 1 is easy to configure and can be adopted in middle-scale distributed environment,
no changing the code.

Sol 2: session synchronization among all web servers

Tomcat server supports cluster through modifying the two configuration files below:
a. server.xml, just opening the <Cluster> node.
b. web.xml, adding <distributable> node.
Sol 2 is applied in small-scale distributed environment, no changing the code.

Sol 3: concentrated cache for sessions

Redis is used as the concentrated cache to store the sessions from all web servers.
Sol 3 is the first choice in large-scale distributed application because it is scalable and robust,
but changing the code.

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/32498/viewspace-2641474/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2012-11-02

  • 博文量
    6
  • 访问量
    3727