Module3-Topic4-Redis Part-1
Module3-Topic4-Redis Part-1
It supports data structures such as strings, hashes, lists, sets, sorted sets
with range queries, bitmaps, hyperloglogs, geospatial indexes with radius
queries and streams.
Redis has built-in replication, Lua scripting, LRU eviction, transactions and
different levels of on-disk persistence, and provides high availability via
Redis Sentinel and automatic partitioning with Redis Cluster.
Redis is written in ANSI C and works in most POSIX systems like Linux,
*BSD, OS X without external dependencies.
Linux and OS X are the two operating systems where Redis is developed
and tested the most, and we recommend using Linux for deploying.
Redis may work in Solaris-derived systems like SmartOS, but the support is
best effort.
• you can persist it either by dumping the dataset to disk every once in a
while, or by appending each command to a log.
When we say in-memory key-value store, by that we mean that the key-value
pairs are stored in primary memory(RAM).
So we can say that Redis stored data in RAM in form of key-value pairs. In Redis,
key has to be a string but value can be a string, list, set, sorted set or hash.
Here name and profession are keys. And we have their respective values on right.
Redis architecture contains two main processes: Redis client and Redis
Server.
Redis client and server can be in the same computer or in two different
computers.
Redis server is responsible for storing data in memory. It handles all kinds of
management and forms the major part of architecture. Redis client can be
Redis console client or any other programming language’s Redis API.
There are three different ways to make Redis persistance: RDB, AOF and
SAVE command.
RDB Mechanism:
RDB makes a copy of all the data in memory and stores them in secondary
storage(permanent storage). This happens in a specified interval. So there
is chance that you will loose data that are set after RDB’s last snapshot.
AOF
AOF logs all the write operations received by the server. Therefore everything is
persistance. The problem with using AOF is that it writes to disk for every operation
and it is a expensive task and also size of AOF file is large than RDB file.
SAVE Command
You can force redis server to create a RDB snapshot anytime using the redis
console client SAVE command.
You can use AOF and RDB together to get best persistance result.
Redis replication is very simple to use and configure master-slave replication that
allows slave Redis servers to be exact copies of master servers.
Redis Sentinel provides high availability for Redis. In practical terms this means
that using Sentinel you can create a Redis deployment that resists without human
intervention certain kinds of failures.
• Monitoring. Sentinel constantly checks if your master and replica instances are
working as expected.
The cluster uses hash partitioning to split the keyspace into 16,384 key
slots, with each master responsible for a subset of those slots.
One port is used for client connections and communications. This is the port
you would configure into client applications or command-line tools.
Failover
When the failing master eventually rejoins the cluster, it will join as a slave
and begin to replicate another master.
Redis has a concept of the hash slot in order to split data. All the data are divided
into slots.
There are 16384 slots. These slots are divided by the number of servers.
If Redis service goes down on one of the nodes in Redis 3-node cluster
setup, its respective slave will be promoted as the master.
• Twitter
• GitHub
• Weibo
• Pinterest
• Snapchat
• StackOverflow
• Flickr
• Digg