Tomcat在内存中会话复制
我们希望在内存中实现会话复制。在我们这样做之前,我们主要关心的是会话对象将如何使用内存?如果会话在一段时间后变大,则会出现内存不足错误,那么除了增加内存大小之外,如何克服这个问题? 如果有人参与这些,请回复我..,提前致谢。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以做的一件事是限制活动会话的数量(maxActiveSessions): http://tomcat.apache.org/tomcat-7.0-doc/config/manager.html#Common_Attributes - 这样您就可以限制会话使用的内存。
另一种选择是使用非粘性会话,以便内存中同时存储的会话数与并发请求数相同。不确定 tomcat 与非粘性会话集成复制的详细信息,但至少 memcached-session-manager 可以管理它们(我必须提到我是这个库的作者)。它还提供 jmx 统计信息,让您可以检查会话内存尺寸。
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.
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). It also provides jmx statistics that allow you to inspect the session memory size.
这不是一个精确的答案,但我强烈建议您阅读此博客。在java中处理大量数据有很多有用的技巧。
如果您在 Linux 上部署,请考虑使用 tmpfs 或ramfs。也许您根本不需要编写代码。
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.
If you deploy on linux, consider using tmpfs or ramfs. Maybe you don't need to code it at all.