2 ms·
Why both redis and memcached?
by trustfundbaby 14y ago
Why both redis and memcached?
- manuelflara 14y agoI can't speak for Parse, but I use both of these technologies in one site. Memcached is, well, for any kind data that you want to cache: results of SQL queries, blocks of the site (HTML), etc. Redis, on the other hand, it's a final data storage on its own (like MySQL, because it's also persistent), but it's faster than MySQL for certain things. For example, for things like "List of profiles I've visited / have visited me recently on Facebook". This seems like a very simple MySQL table and query, but once it becomes big it starts to get slow. On the other hand, you can have one key per user on Redis, like "<id_user>_visit_history" which is a sorted set of <time, id_user>. You could do the same with Memcached (although it doesn't support the same data types), but then it wouldn't be persistent.
- trustfundbaby 14y agoRight ... thats my point. redis is as fast if not faster than memcached for caching exactly the same things you talked about (results of sql queries, blocks of the site etc) so why not just use redis for everything and eliminate memcached.
- shykes 14y agoHere's one possible answer, for one specific use case: http://engineering.pinterest.com/posts/2012/memcache-games/ http://engineering.pinterest.com/posts/2012/memcache-games/
- spimmy 14y agoWe use redis because we use resque extensively for the push notifications architecture. Memcache is superior to redis for simple caching in front of data sources.
- AznHisoka 14y agoAny reason why you haven't tried using Sidekiq, which is much more efficient in terms of using memory resources? Or is Resque just good enough for now?
- spimmy 14y agoHm, well Sidekiq wasn't out when we started developing. :) Memory has never been a constraint for us with resque though. The only problems we've had with it have been things like improper signal handling, pretty easy to deal with.