Search code examples
ruby-on-railsrubydatabaseredisurl-shortener

Advantages of using key-value store for URL shortener?


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?


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