PeterG
PeterG

Reputation: 782

Implementing Auto-complete: Redis vs. Memcached, do I need persistence?

Our site's autocomplete is getting painfully slow, so we're going to implement a caching solution.

I've been reading up on memcached and redis. They are both fast enough (doesn't matter here if one is 10 ms faster). The main differences I'm concerned with is that redis has "persitence". This sounds good but I'm not really sure how it applies to auto-complete or would be useful? As far as I can tell without persistence that just means we'd have to rebuild the cache on server restart. I don't see that being too much of an issue (am I being naive here? lol)

We already have memcached installed, so all things being equal we'd probably just go with that, unless there's a compelling reason that redis would be the superior tool for doing search auto-complete?

Our dataset is about 100K items (could grow by a factor of 2 or 3).

Thx, Peter

Upvotes: 2

Views: 2040

Answers (2)

Joshua Martell
Joshua Martell

Reputation: 7212

Interesting blog post by antirez, on creating an auto-complete system with Redis.

http://antirez.com/post/autocomplete-with-redis.html

Upvotes: 1

Amir Raminfar
Amir Raminfar

Reputation: 34179

How are you doing your auto-compelete? The preferred solution is to have a text-search service such a Solr that can quickly return suggestions. This is the common way and it is very fast. You will never need a caching layer.

That said, let's assume you can't deploy solr right now. Redis is usueful if you can't afford to lose data. Redis persists data to disk so even after a shutdown data is there. To me it sounds like if the cache is a miss then it will just be slow for the first person. Memcache is the right layer here because if the data gets lost you can afford to populate the cache again.

Here is a link how one could do auto-suggest in Solr: What's the best way to implement AutoComplete in the server?

Upvotes: 1

Related Questions