简体   繁体   中英

Servlet in-memory session storage

Most servlet containers seem to store HttpSession data in-memory. I wonder if this might cause a problem if, say, 500 users are logged into a servlet-based web app at the same time. Let's assume I store two values per user, one boolean value isLoggedIn and one integer value userRole. Should I be worried about potential excessive memory consumption by the web app? Up to now, I've mostly done development in PHP where most frameworks let you save session data in an SQL DB. Is there any realistic chance that in-memory storage might cause a problem? Maybe there is a formula to calculate RAM usage per active user session.

If your session data is large, yes you should worry about it. Tomcat has a persistence manager that lets idle sessions be paged out to a database.

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