简体   繁体   English

Tomcat中的内存会话复制

[英]Tomcat in memory session replication

We are looking to implement in memory session replication. 我们正在寻求在内存会话复制中实现。 Before we do that our main concern is how the session objects will use the memory? 在此之前,我们主要关心的是会话对象将如何使用内存? and if session get large after some time will get out of memory error so how to overcome this other than increasing the memory size? 如果会话在一段时间后变大,则会出现内存不足错误,那么除了增加内存大小外,如何克服这一问题? if anybody get into these please reply me.., Thanks in advance. 如果有人进入这些,请回复我..,在此先感谢。

It's not a precise answer, but I strongly recommend you to read this blog. 这不是一个精确的答案,但我强烈建议您阅读博客。 There are many useful tricks to deal with huge set of data in java. 有很多有用的技巧可以处理Java中的大量数据。

If you deploy on linux, consider using tmpfs or ramfs . 如果在Linux上部署,请考虑使用tmpfs或ramfs Maybe you don't need to code it at all. 也许您根本不需要编写代码。

One thing you can do is limiting the number of active sessions (maxActiveSessions): http://tomcat.apache.org/tomcat-7.0-doc/config/manager.html#Common_Attributes - so you can limit the memory used by sessions. 您可以做的一件事就是限制活动会话的数量(maxActiveSessions): http : //tomcat.apache.org/tomcat-7.0-doc/config/manager.html#Common_Attributes-这样就可以限制会话使用的内存。

Another option is to use non-sticky sessions so that there are only as much sessions concurrently stored in memory as there are concurrent requests. 另一种选择是使用非粘性会话,以便内存中并发存储的会话数与并发请求数一样多。 Not sure about the details of the tomcat integrated replication of with non-sticky sessions, but at least memcached-session-manager can manage them (I must mention that I'm the author of this lib). 不确定与非粘性会话进行的tomcat集成复制的详细信息,但是至少memcached-session-manager可以管理它们(我必须提到我是这个库的作者)。 It also provides jmx statistics that allow you to inspect the session memory size. 它还提供了jmx统计信息 ,可让您检查会话内存大小。

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

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