Redis Architecture – (Single Instance, HA, Sentinel, Cluster)

Redis Architecture – (Single Instance, HA, Sentinel, Cluster). Generally, the topic of today’s article is Redis, including its architecture (structure). It’s main domain is it’s an in memory key value data store. In addition, Redis it is currently the most popular data store. Moreover, it is used by major IT brands from all over the world. Another important factor is Redis support from Amazon Elastic Cache ,which makes it a very powerful and mandatory key value data store.

If you want to learn about Redis Architecture – (Single Instance, HA, Sentinel, Cluster) you have arrived to the perfect place.

What is Redis Architecture?

First of all, a very important aspect of Redis architecture, it is it’s multiple and single instance models. For instance, the single instance -a very simple implementation in Redis, allows the user to run and set up small instances, that helps in the development and speed of services.

Altogether, Redis cluster replication is implemented to define the meaning of the project. Also, the main advantage is linear definition, scalability and high performance. Besides, Redis has no proxy, and also uses asynchronous replication.  Basically, Redis use of a primary replica architecture supports asynchronous replication with the data being replicated to multiple servers.

Therefore, if the primary server goes down, the primary slave server provides fast read and fast recovery. Certainly, Redis provides real time backups. Fundamentally though, Redis is not designed for consistent, long lived databases. Comparatively, Redis provides a basic slave architecture in the form of one master node and other secondary nodes that accept reads. Importantly, secondary nodes do not accept write requests.

Important discoveries of Redis server :

  • Includes Master Slave, Replication, High Availability and Sentinel and also defined one cluster in Redis server.
  • This includes key value database servers and data structure servers. Redis is an in-memory database, so all data is stored in memory.

Popular Redis Use Cases

1. Session store

In this instance, Redis- a highly available and durable in memory data store, is a popular choice among application developers to store and manage session data for web applications. What is more, it provides the sub millisecond latency, scalability, and fault tolerance required to manage session data such as user profiles, credentials, session state, and per-user personalization.

2. Chat, messaging, and queues

Importantly, Redis supports Pub/Sub with pattern matching and various data structures such as lists, sorted sets, and hashes. Consequently, it supports high performance chat, real time comment threads, social media feeds, and server interactions. Concurrently, the Redis list data structure simplifies the implementation of lightweight queues. Additionally, it’s lists provides atomic operations and blocking capabilities, making them suitable for reliable message brokers or for a variety of applications that require circular lists.

3. Machine Learning

Modern data driven applications require machine learning to rapidly process vast amounts, variety, and velocity of data and automate decision making. For use cases such as fraud detection in gaming and financial services, real time bidding in advertising technology, and matchmaking in dating and sharing, it is its ability to process real time data and make decisions in tens of milliseconds. Especially, Redis provides a fast, in memory data store for quickly building, training, and deploying machine learning models.

4. Caching

An excellent choice for implementing a highly available in memory cache to reduce data access latency, increase throughput, and reduce load on relational or NoSQL databases and applications. Furthermore, Redis delivers frequently requested items with sub millisecond response times and scales easily to higher workloads without scaling a more expensive backend. Basically caching database queries results, caches persistent sessions, web pages, and frequently accessed objects such as images, files, and metadata. These are all popular examples of caching in Redis.

5. Real time analytics and streaming

Used as an in memory data store for ingesting, processing, and analysing real time data with sub millisecond latency in conjunction with streaming solutions such as Apache Kafka and Amazon Kinesis

Redis Architecture Description

Architecture of Redis contains two main processes. First is a Redis client and the second is a Redis server. You will install the Redis server and client on the same machine or on two different machines. Multiple clients simultaneously connect to the same server to process requests.

Servers are responsible for storing data in memory. Following, it handles all control and is an important part of the architecture. Being that, Redis server is a very important part of it’s architecture. A Redis client is nothing more than a Redis console with a programming language for the Redis API. Here, Redis stores all data in the main memory. Remember, Redis main memory is volatile, so restarting the server will result in data loss. 

Redis supports the following storage platforms:

The following example shows two parts, client side and server side:

  • AOF – First of all allows data to be saved by logging all write operations received from the server.

Save the command –  Important is save command forces the Redis server to create RDB snapshots at any time.

  • RDB – Copies all data from memory and saves it to persistent storage at set intervals.

Replication is also supported for fault tolerance and data availability. Also you can increase storage capacity by grouping two or more servers in a given cluster.

Single Redis instance

A Redis instance usually represents the server process of the Redis software. One physical/virtual server runs multiple software processes, Redis or whatever. This allows you to have a server with multiple Redis instances.

Each Redis instance has a launch mode and role. Possible modes of operation: standalone or cluster. Possible roles: Master or Slave. Also you cannot have more than one master instance in standalone mode. Moreover, the master instance is responsible for the entire database (regular/numbered databases are just namespaces within this database). Optionally, one or more slaves can be added to provide high availability (such as from Sentinel) or to offload read operations from the master.

In cluster mode, databases (clusters do not support shared/numbered databases) are partitioned into hash slots. Each master instance belongs to a cluster is responsible for one or more slots at any given time. 

A cluster master instance contains slave instances, but it is typically used only for high availability purposes, which is handled internally by the cluster. Scaling a cluster is usually achieved by simply adding a new master and moving its slots. In the context of a Redis cluster, a node is simply a server running one or more instances.

Pros

  • Simple and classical architecture.
  • Easy deployment and configuration.

Cons

  • Redis is a single threaded engine, so its performance is limited by the processing power of a single core processor. Generally main bottleneck is the CPU, which limits the number of instructions that are executed on a single computer.
  • There is no standby (slave) node for real-time data synchronization.
  • Not suitable for data reliability requirements.

Redis Sentinel

Sentinel is a solution that simplifies Redis instance management. As of Redis 2.8, a stable version of Redis Sentinel is available. So, sentinel is a standalone application that runs in the background. It monitors master and slave instances, notifies of changes, manages automatic failover in case of master failure, and acts as a configuration provider.

Secondly the quorum is configurable and represents only the number of sentries that must agree when the master is down. In a failover scenario, Sentinel instances tries to reach consensus, and a minimum of 3 (odd) sentinel instances will prevent most problems. These three Sentinel instances are expected to fail independently of each other, so they must be hosted on separate physical servers or virtual machines.

Pros

  • Works as long as one master instance is available. It survives the failure of any sub instance.
  • Multiple slave nodes replicates data from the master node.
  • High availability allows you to create Redis Sentinel deployments that sustain certain outages without human intervention.
  • With three nodes, you build up a fully functional Sentinel deployment.

Cons

  • Slaves serve reads, but asynchronous replication can result in stale reads.
  • Redis Sentinel must be supported by the client and client holds half of the responsibility.
  • Non scalable writes must go to the master and cannot solve the read write separation problem.
  • Because it does not separate data, the use of masters and slaves becomes unbalanced.

Redis Cluster

A cluster must have at least three master nodes to function properly, and Redis recommends that each master node have at least one slave node and that Redis version 3.0 or later is required.

Each node must open two TCP connections. Standard Redis TCP port for client service. The second port is used for the cluster bus, which is communication between nodes based on binary protocol.

If a master becomes unavailable due to network failure or software/hardware failure, the other master notifies the cluster bus and enters a failover state. Appropriate slaves of the unreachable master step forward and are promoted to the new master.

Pros

  • Data is distributed across multiple nodes based on hash slots and the data distribution is dynamically adjusted.
  • Generally perform automatic failover by using the slave device as a data backup. Support for a master slave structure eliminates the need for additional failover handling and has master failover built in.
  • No central architecture and automatically distributes data across multiple nodes.

Cons

  • Replication structure allows only one level, so slave nodes only replicate master nodes.
  • It is impossible to provide strong consistency. In practice, this means that Redis clusters might lose system verification records for clients under certain circumstances.
  • Totally unavailable, in case of catastrophic failure the cluster will halt, if most of the masters are unavailable.
  • Not all libraries support it. Lack of client library implementation in Redis cluster.

Redis HA

Redis HA (high availability) is most commonly used as a cache to store frequently accessed data. This allows Redis to be used as a powerful caching layer on the server, as it not only improves the user experience and performance, but also leads to faster loading and better performance of web applications.

Connecting to a standalone Redis server is usually straightforward. However, if you want high availability, you should use Redis Sentinel. This is a process that automates and simplifies replication failover.

Thank you for reading Redis Architecture – (Single Instance, HA, Sentinel, Cluster). We shall conclude this article now. 

Redis Architecture – (Single Instance, HA, Sentinel, Cluster) Conclusion

In conclusion, this article introduced the Redis architecture with it’s four components. We discussed the advantages and disadvantages of various Redis solutions. There are many factors to consider when choosing the best solution for your business case, so pick with care.

If you want to know more about Redis have a look our blog over here.

Avatar for Kamil Wisniowski
Kamil Wisniowski

I love technology. I have been working with Cloud and Security technology for 5 years. I love writing about new IT tools.

0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x