Skip to main content

Memcached Vs Redis : Which one to pick ??

Memcached is a general-purpose distributed memory caching system. It is often used to speed up dynamic database-driven websites by caching data and objects in RAM to reduce the number of times an external data source (such as a database or API) must be read.
Redis is a flexible, open source and advanced key-value store. It is referred to as a “data structure server” where keys can contain strings, lists, hashes, sets and sorted sets of strings.
redis_memcached_new
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 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.
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.

Comments

Popular posts from this blog

Sexy C#

Download samples   Table of Contents   1.   Introduction  2.   Background    3.   Sexy Features 3.1.   Extension Methods   3.2.   Anonymous Type   3.3.   Delegate   3.4.   Lambda Expression 3.5.   Async-Await Pair   3.6.   Generics   4.   Conclusion   1. Introduction     C#  is a very popular programming language. It is mostly popular in the .NET arena. The main reason behind that is the C# language contains so many useful features. It is actually a multi-paradigm programming language. Q.   Why do we call C# a muti-paradigm programming language? A.  Well, C# has the following characteristics:  Strongly typed   Object Oriented  Functional  Declarative Programming  Imperative Programming   Component based Programming Dynamic Programming ...

Python Subprocess Module

Subprocess A running program is called a  process . Each process has its own system state, which includes memory, lists of open files, a program counter that keeps track of the instruction being executed, and a call stack used to hold the local variables of functions. Normally, a process executes statements one after the other in a single sequence of control flow, which is sometimes called the main thread of the process. At any given time, the program is only doing one thing. A program can create new processes using library functions such as those found in the os or subprocess modules such as  os.fork() ,  subprocess.Popen() , etc. However, these processes, known as  subprocesses , run as completely independent entities-each with their own private system state and main thread of execution. Because a subprocess is independent, it executes concurrently with the original process. That is, the process that created the subprocess can go on to work on other thing...

How To Configure a Linux Service to Start Automatically After a Crash or Reboot

Part 1: Practical Examples Tutorial Series Introduction This tutorial shows you how to configure system services to automatically restart after a crash or a server reboot. The example uses MySQL, but you can apply these principles to other services running on your server, like Nginx, Apache, or your own application. We cover the three most common init systems in this tutorial, so be sure to follow the one for your distribution. (Many distributions offer multiple options, or allow an alternate init system to be installed.) System V  is the older init system: Debian 6 and earlier Ubuntu 9.04 and earlier CentOS 5 and earlier Upstart : Ubuntu 9.10 to Ubuntu 14.10, including Ubuntu 14.04 CentOS 6 systemd  is the init system for the most recent distributions featured here: Debian 7 and Debian 8 Ubuntu 15.04 and newer CentOS 7 Background Your running Linux or Unix system will have a number of background processes executing at any time. These proc...