Django's builtin cached_db session allows me to use memcached to store session data, and write through to db for persistence.
While some applications use redis as their session store (instagram for one).
What is the pros and cons of these solutions?
p.s. I am not asking about the comparison between memcached and redis, which this question Memcached vs. Redis? already provides very good answers. I am asking about which one is better in case of a session system.
In Memcached keys are expired when memory limit is reached even if their ttl is still due. This way some of your users will loose their sessions. In Redis you don't have memory limit by default, so you won't run into this problem. You need, however, manage your memory to ensure that Redis always has enough memory. You can also switch on memory limit in Redis making it to behave similar to Memcached (see MAXMEMORY
configuration option).
Also take a look at Cookie-based sessions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With