Redis A persistent key-value database

Similar presentations

2
MySQL & memcache It’s common to use MySQL as the backend for storing and retrieving what are essentially key/value pairs. In some scenario, we needs to maintain a bit of state, session data, counters, small lists, and so on. When MySQL isn’t able to keep up with the volume, we often turn to memcached* as a write-thru cache. But there’s a bit of a mis-match at work here. Memcached doesn’t have much in the way of a query language or server-side operations it can perform on the data. MySQL lies at the other end of the spectrum. It has a rich query language and support for all sorts of server-side processing on the dataSo when we combine the two, our app has to know it’s talking to both and deal with coordinating data changes between the cache and the back-end server. *memcached is a high-performance, distributed memory object caching system, generic in nature, but intended for use in speeding up dynamic web applications by alleviating database load.

3
redis A fast, efficient key/value store that provides a reasonable set of server-size operations aimed at making the most common operations trivial.

7
why redis? readily available client APIs available for a number of languages, including: RubyPythonPerlPHP ErlangTCLLuaJava Performance – the overriding focus for redis is performance – 80, ,000 (or more) operations per second on modest modern hardware is likely enough to make a dramatic difference to most applications. – much of this performance comes from it’s minimal feature set. – carefully chosen features that can be supported by very fast algorithms and, in come cases, even lock-free atomic operations.

8
why redis? Durability and Availability – Unlike memcached, redis can save its state to disk so that you can shut down a server without losing all the data. – SAVE: save data to disk (synchronously) – BGSAVE: save data to disk (asynchronously) – LASTSAVE: get timestamp of last saved data – For performance reasons, redis doesn’t log every change to disk as it happens (then it’d be a lot more like a database). – Instead, it can be configured to save a copy of the database to disk after a certain amount of time has passed or a certain threshold of changes have occurred in the data. The method of writing to disk requires no locking and has no consistency problems. The server simply forks a child which inherits a copy of the data it can write to disk. That process of writing to disk should take somewhere from a few seconds to maybe a minute or two. Uses Copy-on-write optimization technique. redis also has built-in support for master/slave replication, so it’s possible to scale in read-heavy environments simplicity + functionality+ performance = redis