简体   繁体   中英

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.

If you deploy on linux, consider using tmpfs or 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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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