redis vs memcached

6
Redis Vs Memcached Memcached or Redis? It's a question that nearly always arises in any discussion about squeezing more performance out of a modern, database-driven Web application. When performance needs to be improved, caching is often the first step employed, and Memcached and Redis are typically the first places to turn. Redis and Memcached Redis The name Redis means RE mote DI ctionary S erver. Redis is an open source, BSD licensed, advanced key-value store. It is often referred to as a data structure server since keys can contain strings, hashes, lists, sets and sorted sets. Redis is written in c. Redis is an open source, advanced key-value store and a serious solution for building high-performance, scalable web applications. Redis has three main peculiarities that set it apart from much of its competition: Redis holds its database entirely in memory, using the disk only for persistence. Redis has a relatively rich set of data types when compared to many key-value data stores. Redis can replicate data to any number of slaves. By Gaurav Agrawal

Upload: gaurav-agrawal

Post on 10-Feb-2017

325 views

Category:

Technology


1 download

TRANSCRIPT

Page 1: Redis vs Memcached

Redis Vs MemcachedMemcached or Redis? It's a question that nearly always arises in any discussion about squeezing more performance out of a modern, database-driven Web application. When performance needs to be improved, caching is often the first step employed, and Memcached and Redis are typically the first places to turn. 

Redis and Memcached

Redis The name Redis means REmote DIctionary Server. Redis is an open source, BSD licensed, advanced key-value store. It is often referred to as a data structure server since keys can contain strings, hashes, lists, sets and sorted sets. Redis is written in c.

Redis is an open source, advanced key-value store and a serious solution for building high-performance, scalable web applications.

Redis has three main peculiarities that set it apart from much of its competition:

Redis holds its database entirely in memory, using the disk only for persistence. Redis has a relatively rich set of data types when compared to many key-value

data stores. Redis can replicate data to any number of slaves.

Memcached

Memcached is an open source, high-performance, distributed memory caching system intended to speed up dynamic web applications by reducing the database load. It is a key-value dictionary of strings, objects, etc, stored in the memory, resulting from database calls, API calls, or page rendering.

By Gaurav Agrawal

Page 2: Redis vs Memcached

Memcached was developed by Brad Fitzpatrick for LiveJournal in 2003. However, it is now being used by Netlog, Facebook, Flickr, Wikipedia, Twitter, and YouTube among others.

The key features of Memcached are as follows − It is open source. Memcached server is a big hash table. It significantly reduces the database load. It is perfectly efficient for websites with high database load. It is distributed under Berkeley Software Distribution (BSD) license. It is a client-server application over TCP and/or UDP.

Memcached is not − a persistent data store

a database

application-specific

a large object cache

fault-tolerant or

highly available

Redis vs MemcachedSimilarities

Both Memcached and Redis are in-memory. key-value data stores. They both belong to the NoSQL family. Both are based on the same key-value data model. They both keep all data in RAM, which makes them useful as a caching

layer. In terms of performance, the two data stores are also remarkably similar,

exhibiting almost identical characteristics (and metrics) with respect to throughput and latency.

By Gaurav Agrawal

Page 3: Redis vs Memcached

Differences

The main differences between them are listed below:

Installation:Comparing ease of Installation Redis is much easier. No dependencies required.

Memory Usage:For simple key-value pairs memcached is more memory efficient than Redis. If you use Redis hashes, then Redis is more memory efficient.

Persistence:If you are using Memcached then data is lost with a restart and rebuilding cache is a costly process. On the other hand, Redis can handle persistent data. By default, Redis syncs data to the disk at least every 2 seconds.

Replication:Memcached does not supports replication. Whereas Redis supports master-slave replication. It allows slave Redis servers to be exact copies of master servers. Data from any Redis server can replicate to any number of slaves.

Storage type:Memcached stores variables in it’s memory. It retrieve any information directly from the servers memory instead of hitting the database again. On the other hand, Redis is like a database that resides in memory. It executes (read and write) a key/value pair from its database to return the resultset and all data

By Gaurav Agrawal

Page 4: Redis vs Memcached

resides in memory. Developers are using Redis also for real-time metrics, analytics.

Read/Write Speed:Memcached is very good to handle high traffic websites. It can read lots of information at a time and give you back at a great response time. Redis can also handle high traffic on read but also can handle heavy writes as well.

Data Structure:Memcached uses string and integer as data structure. Everything you save can be either one or the other. With integer, the only data manipulation you can do is adding or subtracting them. If you need to save arrays or objects, you will have to serialize them first and then save them. To read them back, you will need to un-serialize.

In comparison Redis has a stronger data structures. It can handle not only strings, integer but also binary-safe strings, lists of binary-safe strings, sets of binary-safe strings and sorted sets.

Key Length:Memcached key length has a maximum of 250 bytes, whereas Redis key length has a maximum of 2GB.

Redis can be used as a memcached on steroids because is as fast as memcached but with a number of features more. Like memcached, Redis also supports setting timeouts to keys so that this key will be automatically removed when a given amount of time passes.

So, If you need advanced data structures or disk-backed persistence, you should look into Redis. On the other hand, you might want to stick to Memcached for its simplicity, reliability and speed.

By Gaurav Agrawal

Page 5: Redis vs Memcached

By Gaurav Agrawal