用于tomcat的分布式HTTP会话状态服务器 [英] Distributed HTTP session state server for tomcat

查看:88
本文介绍了用于tomcat的分布式HTTP会话状态服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的一个Spring MVC Web应用程序部署在多个Web服务器上,tomcat 7和LB位于前端,以平衡请求并将其分发到适当的tomcat服务器。

One of our Spring MVC web application is deployed on multiple web servers with tomcat 7 and LB is at front to balance and distribute the requests to appropriate tomcat server.

这个web farm的问题是每个tomcat服务器都能够存储和检索自己的HTTP会话,但LB可以向任何一个Web服务器发送请求。因此,如果用户通过tomcatServer1为登录页面服务,那么它的HTTP会话将在其受尊重的服务器上创建,并且可能发生对于仪表板页面LB的第二次请求将其发送到没有HTTP会话的tomcatServer2,导致用户再次被重定向登录页面。

Problem with this web farming is each tomcat server is able to store and retrieve its own HTTP session, but LB can send requests to any one of web server. So if a user is served for login page through tomcatServer1 then it's HTTP session will be created on it's respected server and it may happen that for second request of dashboard page LB sends it to tomcatServer2 where HTTP session is not available, resulting user is again redirected to login page.

为了解决这个问题,


  1. 我们正在使用Sticky会话LB上的属性,因此如果用户(HTTP会话+用户的公共IP)首次从tomcatServer1提供,那么它将绑定到该服务器。设置Sticky Session没有用,因为它没有平等地利用所有服务器。

  2. 另一种方法是,开发我们自己的会话状态服务器并在服务器上部署,然后所有服务器都应该与该服务器通信用于存储和检索会话对象/数据。

  3. 提供自定义 SessionManager 到Servlet容器。

  1. we are using "Sticky Session" property on LB, so that if a user (HTTP session + user's public IP) is first time served from tomcatServer1 then it will get bound to that server. Setting "Sticky Session" is not helpful as it's not utilizing all servers equally.
  2. Another way is, develop our own session state server and deploy on a server then all server should communicate to that server for storing and retrieving session object/data.
  3. Providing custom SessionManager to Servlet Container.

关于#2,如果我们能够开发状态服务器然后我还要修改与 HttpSession.setAttribute() HttpSession.getAttribute()相关的代码。 所以问题是,是否可以覆盖方法setAttribute&的 HttpSession 的实现。 getAttribute?同样关于#3,我不知道这个解决方案是否会提供分布式状态会话服务器?

About #2, If in case we able to develop state server then also I have to modify the code to related to HttpSession.setAttribute() and HttpSession.getAttribute(). So question is, is it possible to override implementation of HttpSession for methods setAttribute & getAttribute? Also About #3, I don't know whether this solution will provide distributed state session server?

推荐答案

我使用python为tomcat开发了会话状态服务器

I developed session state server for tomcat using python.

由于这个原因,我不需要更改已经为创建/访问和销毁会话而编写的代码。此外,由于存在处理和存储会话的单独服务器/服务,因此不需要主集群。

Due to this I don't need to change the code already written for creating/accessing and destroying session. Also as there is separate server/service which is handling and storing session so not master cluster is needed.

这篇关于用于tomcat的分布式HTTP会话状态服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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