简体   繁体   English

tomcat中的会话迁移/复制

[英]session migration/replication in tomcat

I have N number off application servers all behind a hardware load balancer.Now i want to make these app server session aware? 我有N个应用程序服务器都在硬件负载均衡器后面。现在我想让这些应用服务器会话知道吗?

If i create a session on one appserver other app server will not be aware of it.After googling i found 2 approaches 1)Generate a random String .Put this randomString in cookies and store these in Db table with creation time.Very time when request comes in check this db table.But this opration is heavy 2)Use tomcat session migration?Now am sure if this works correctly .Does this work correctly? 如果我在一个appserver上创建一个会话,其他应用服务器将不会知道它。谷歌搜索后发现2个方法1)生成一个随机字符串。在cookies中输入这个randomString并将它们存储在创建时间的Db表中。请求时的非常时间来检查这个db表。但这个操作很重2)使用tomcat会话迁移?现在确定这是否正常。这是否正常工作?

Am using TOMCAT as my web server (Cant use other) 我使用TOMCAT作为我的网络服务器(不能使用其他)

How can i configure tomcat for session migration/replication?Any tutorial? 如何为会话迁移/复制配置tomcat?任何教程?

Session replication is a pretty broad topic. 会话复制是一个非常广泛的主题。 Have you tried the Tomcat built-in replication yet? 您是否尝试过Tomcat内置复制?

http://tomcat.apache.org/tomcat-6.0-doc/cluster-howto.html http://tomcat.apache.org/tomcat-6.0-doc/cluster-howto.html

If that's not good enough for you, you can look for commercial tools like Terracotta Web Sessions. 如果这对您来说不够好,您可以寻找Terracotta Web Sessions等商业工具。 Or you could develop your own session cache around for example memcached. 或者您可以开发自己的会话缓存,例如memcached。

I am not aware about the session affinity when working behind a hardware load balancer ,However for the scenario that you have mentioned as per your googling results for the 1st part you can use Memcache instead of cookie+database to reduce the operation response time . 在硬件负载均衡器后面工作时我不知道会话亲和性。但是对于您根据第一部分的Google搜索结果提到的场景,您可以使用Memcache而不是cookie + database来减少操作响应时间。 A simpler approach when using Memcache can be using "memcached-session-manager" .The setup and configuration is easy as mentioned at at http://code.google.com/p/memcached-session-manager/wiki/SetupAndConfiguration . 使用Memcache时更简单的方法是使用“memcached-session-manager” 。如http://code.google.com/p/memcached-session-manager/wiki/SetupAndConfiguration所述,设置和配置很简单。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM