Question

I researched a lot of URL shorteners for Rails in the web, and a majority of them delegate the persistence feature to redis.

Can anyone explain to me the benefits of using a key-value store, like Redis, instead of the database for persisting and accessing short URLs?

Was it helpful?

Solution

Databases like redis are optimized for storing lots of small values (such as links and their short urls) because they are loaded up into memory (ram). This means when a call is made to redis it reads data from ram (faster) instead of the hard drive (slower).

EDIT:

If you would like to learn more, this is a great writeup of the advantages and shortcomings of the top no-sql databases. Definitely a great reference.

http://kkovacs.eu/cassandra-vs-mongodb-vs-couchdb-vs-redis

OTHER TIPS

It is much simpler to shard, scale and replicate a key-value store than a SQL database, so it makes sense to use one when data suits

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top