Introduction to Redis Architecture
Redis architecture contains single as well as multiple instance models. It mainly focuses on a single redis instance, redis HA, redis cluster, and redis sentinel. As per our use case, we need to select the architecture of redis. The single instance is a very straightforward deployment in a redis, it will allow the user to run and set the small instances which helps to grow and speed services.
Key Takeaways
- It includes a key-value database server as well as a data structure server. Redis is a memory database, so all data is stored in memory.
- It contains master slave, replication, high availability, and sentinel, we have also defined a single cluster in a redis.
What is Redis Architecture?
Redis cluster replication architecture is implemented from the redis goals for defining the design importance. It defines linear scalability and high performance. There are no proxies, asynchronous replication is used, and no merge operations are carried out. Redis will use a primary replica architecture that supports asynchronous replication, with data replicated to multiple replica servers.
When the primary server fails, the primary slave server provides fast read performance and quick recovery. It offers point-in-time backup. Basically, redis is not designed to be a consistent and long-lasting database. Redis provides the primary slave architecture as a single node primary and another node secondary that accepts read operations. The secondary node is not accepting write requests.
Explanation of Redis Architecture
It contains two main processes, first is the redis client and another is the redis server. We can install the redis server and client in the same system or we can also install the same on two different machines. Multiple clients are connected to a single server at the same time for processing their requests.
Below image shows the architecture of redis as follows:
Redis server is responsible for storing data in memory. It will handle all the management and forms an important part of the architecture. Redis server is a very important part of the architecture. Redis client is nothing more than a redis console with a programming language for the redis API. Redis stores all data in primary memory. Because Redis primary memory is volatile, we lose data when the server is restarted. Redis supports the following platforms for data persistence.
The following example shows two parts, one client and one server.
- RDB – RDB makes a copy of all data from memory and stores it in permanent storage at the specified interval that we have defined.
- AOF – This logs all write operations received from the server, allowing the data to be persistent.
- Save Command – By using the save command, the Redis server forces the creation of an RDB snapshot at any time.
Redis also supports replication for fault tolerance and data accessibility. We can group two or more servers from the specified cluster to increase storage capacity.
Redis Architecture Master Slave
Redis master slave is very easy to use. One master server and one or more secondary slave servers will be included. It is simple to configure the redis master slave architecture, which will allow us to use redis servers as exact copies of the master server. The architecture of redis master slave is shown below. We can see in the figure below that we have defined a single master server as well as two slave servers.
They will have two parts as follows:
- Master
- Slave
While defining the master slave architecture, master accepts the read and write operations while the slave accepts only read operations.
There is a single master and multiple slave servers when using master slave architecture. All write operations are routed to the master, increasing the load on the master server. If the master fails, the entire master slave architecture is defined as a single-point failure. Redis master slave architecture is not supporting scaling at the time our user is growing. As we know, data is written on the master server, and copies of that data are sent to the secondary server. The replica server in a master slave architecture will support read operations and will also be useful during failover.
Redis Architecture Processes
Basically, it consists of two main processes:
- Redis client
- Redis server
In it, both processes are very important. Basically, the redis client contains multiple processes whereas redis server contains a single process. We can install the redis client on the same machine where our redis server exists, also we can install the redis client on another system.
The below diagram shows the processes as follows:
In the above example, we can see that the redis client is used to send the request to the redis server. After sending the request, the redis server checks it. Before checking the request, it will authenticate the user. After successful authentication, it will process the request and return the result to the user. If authentication fails, the client will receive an authentication failure error. At the time of defining the processes, three mechanisms are used i.e. AOF, RDB, and save command. The redis client and redis server are important processes in the architecture of redis.
Replication
Redis replication architecture is a technique that uses multiple computers to enable data access and fault tolerance. In a replication environment, multiple computers share data with one another, so if one or more computers fail, data is still available on other computers.
In the redis replication architecture, all slaves contain the same data as the master. When a new slave is added, the server master automatically syncs data to the newly added slave. In the redis replication architecture, all queries are redirected to the master server; if the master detects any write operations, it will replicate data to the slave server. If a large number of read operations occur, the master server will distribute them to the slave server.
If suppose slave server fails then the environment is also working or, there is no disruption in data consistency. When the server starts working again the master again sends the updated data to the slave server.
The below figure shows the architecture of redis replication as follows. In the below figure, we can see that one master and multiple replica servers.
If the master server crashes and loses all of its data, we are converting the slave to the master. Replication will assist us in the event of a disc failure, as well as in the event of hardware failure and the execution of read queries.
FAQ
Given below are the FAQs mentioned:
Q1. Which process are we using in redis architecture?
Answer: While using redis architecture we are defining mainly two processes i.e. redis client and redis server.
Q2. Which mechanism we are using for data persistence in it?
Answer: We are using three mechanisms in it for data persistence save command, AOF, and RDB.
Q3. What is the use of RDB in redis architecture?
Answer: In it, RDB is used to make the copy of data from memory, after making the copy it will store data on disk. It will be used for data consistency.
Conclusion
For defining the design importance, the redis cluster replication architecture is implemented from the redis goals. The architecture of Redis defines linear scalability and high performance. Redis architecture includes both a single instance model and multiple instances, models. It is mainly concerned with a single redis instance, redis HA, redis cluster, and redis sentinel.
Recommended Articles
This is a guide to Redis Architecture. Here we discuss the introduction, redis architecture master slave, processes, and replication. You may also have a look at the following articles to learn more –