Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pros and Cons of using Redis vs memcached+db as Django's session system?

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.

like image 641
NeoWang Avatar asked Nov 02 '22 02:11

NeoWang


1 Answers

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.

like image 94
Suor Avatar answered Nov 09 '22 15:11

Suor