多个tomcat实例之间的Tomcat会话 [英] Tomcat session between multiple tomcat instance

查看:85
本文介绍了多个tomcat实例之间的Tomcat会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有10个Tomcat实例都运行同一个Web应用程序.我们使用硬件负载平衡器,它将请求转发到任意服务器.在这种情况下,如何在所有Tomcat实例之间维护会话?

We have 10 Tomcat instances all running the same web application. We use a hardware load balancer, and it forwards the requests to an arbitrary server. How can I maintain sessions across all Tomcat instances in this situation?

推荐答案

您需要使用Tomcat的群集在节点之间提供会话复制.

You need to use Tomcat's clustering to provide session replication between nodes.

您还应该考虑使用粘性会话,因为将每个请求定向到任意服务器需要每个服务器始终具有最新的会话数据.这在时间,网络带宽和服务器内存上都很昂贵.还有一个问题,许多客户端并行发送多个请求.如果他们转到不同的服务器,他们将看到不同的会话状态.

You should also consider using sticky sessions as directing each request to an arbitrary server requires that every server has the latest session data at all times. That is expensive in time, network bandwidth and server memory. There is also the issue that many clients send multiple requests in parallel. If they go to different servers they will see different session states.

对于10台服务器,您应该考虑使用 BackupManager ,它在当前节点(该会话的主节点)和一个其他节点(该会话的备份节点)上维护会话状态节点仅知道该会话的主节点和备用节点.默认的 DeltaManager (在所有节点上都保持会话状态)不会随着网络流量随节点数的平方的增加而缩放(对于 BackupManager ,网络流量会缩放线性).请注意,一个节点充当所有会话的备份是一个常见的误解.这是不正确的.备份分布在群集周围,因此对于具有60个活动会话的4节点群集(A,B,C,D),则节点A将具有15个主会话(60/4),对于与B上的主节点的会话有5个备份,与C上的主服务器的会话有5个备份,与D上的主服务器的会话有5个备份.

With 10 servers you should consider the BackupManager which maintains session state on the current node (the master node for that session) and one other node (the backup node for that session) with all the other nodes only knowing the master and backup node for that session. The default DeltaManager (which maintains session state on all nodes) does not scale as the network traffic increases with the square of the number of nodes (with the BackupManager the network traffic scales linearly). Note that it is a common misconception that one node acts as the backup for all sessions. This is incorrect. The backups are distributed around the cluster so for a 4 node cluster (A,B,C,D) with 60 active sessions then node A will have 15 master sessions (60/4), 5 backups for sessions with the master on B, 5 backups for sessions with the master on C and 5 backups for sessions with the master on D.

这篇关于多个tomcat实例之间的Tomcat会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆