Search code examples
performancenosqlhttpsession

HttpSession store in db for performance reason


Suppose that we have a performance-oriented applications works in cluster. It contains a lot of users.It known that the session is replicated poorly so application can be badly scalable.Of course the best way is create application as stateless. (without serializations between nodes ) But my question is : When we decide keep HttpSession in some storage e.g Redis or memcached ?

You think is a good idea keep HttpSession in some nosql instance ?

Thanks


Solution

  • In-memory databases have two major drawbacks:

    1. their capacity is limited to the RAM of the server machine (they could store more data through swapping, but that would pretty much defeat their purpose)
    2. when they go down for whatever reason, all data is lost

    So the question is: how important is your session data? When you lose the sesson data of a user, either because you have to drop it to make room for newer sessions or because you have to reboot the database server, what will that mean? Will they just have to log back in, or will they lose valuable data?

    Note that there is also memcacheDB, which works just like memcached (literally! it was designed to be used as a drop-in replacement) but backs up all data on disk. That's a good alternative to Memcached when data loss is not acceptable.