5 Ağustos 2021 Perşembe

Redis Cluster Mode With Shards - Availability İçindir

Giriş
Cluster mode kullanırken Sentinel gerekmez. Açıklaması şöyle
You don’t need Sentinel when using Redis cluster.
Redis Cluster performs automatic failover if any problem occur in any primary instance.
Cluster Mode Nedir?
Verinin tek bir düğüme sığmaması ve availability yüzünden dağıtılmasıdır. Açıklaması şöyle
But what if we’re dealing with large data that can’t be contained in one node? Redis supports clusters to shard your data across multiple nodes.
Cluster Mode iki şekilde olabilir
- Sharding with a Redis cluster
- Sharding and Replication with Redis cluster - En çok kullanılan bu

Slots Nedir
The entire keyspace in Redis Clusters is divided into 16384 slots (called hash slots) and these slots are assigned to multiple Redis nodes. A given key is mapped to one of these slots and the hash slot for a key is computed:

HASH_SLOT = CRC16(key) mod 16384

In most cases, you don’t need to know these internals as Redis will take care of the push and pull of data from the right cluster.
Açıklaması şöyle
Redis Cluster does not use consistent hashing, but a different form of sharding where every key is conceptually part of what we call a hash slot. There are 16384 hash slots in Redis 
Cluster, and to compute what is the hash slot of a given key, we simply take the CRC16 of the key modulo 16384. Every node in a Redis Cluster is responsible for a subset of the hash slots, so for example you may have a cluster with 3 nodes, where:

- Node A contains hash slots from 0 to 5500.
- Node B contains hash slots from 5501 to 11000.
- Node C contains hash slots from 11001 to 16383.

1. Sharding With Cluster Nedir?
Açıklaması şöyle. Yani verinin dağıtılmasıdır.
If data is to be sharded to several nodes, Redis offers an open-source version of Redis Cluster. It supports building a cluster from several replication groups. Data within the cluster is sharded over 16 384 slots. Slot ranges are determined among Redis nodes.

Nodes within the cluster communicate over a separate open port to know their neighbors’ statuses. To work with Redis Cluster, the app should use a special connector.
Şeklen şöyle.


2. Sharding And Replication With Cluster Nedir?
Şeklen şöyle. Yani verinin dağıtılması ve her düğümün de replica'sının olmasıdır
Şeklen şöyle
Açıklaması şöyle
What is the Redis Cluster?

Data is automatically partitioned over many Redis nodes, resulting in a stable and reliable data service. So automatically split your dataset among multiple nodes. A cluster must have at least three master nodes to work correctly, with Redis recommending that each master have at least one slave and requires Redis version 3.0 or higher.

Every node should open two TCP connections. The standard Redis TCP port for serving clients. The second port is utilized for the Cluster bus, which is a binary protocol-based node-to-node communication.

If a master instance becomes unavailable due to network failures or software/hardware failures, the other Master nodes will notice by the Cluster bus and reach a failover state. After then, a suitable slave of the unavailable Master node will step forward and be promoted to become the new Master.
Cluster istemciyi doğru sunucuya yönlendirir. Açıklaması şöyle
In Redis Cluster nodes don't proxy commands to the right node in charge for a given key, but instead, they redirect clients to the right nodes serving a given portion of the keyspace. 
İyi ve kötü yönleri şöyle

Redis Cluster Pros:
- It has no central architecture, automatically splits data among multiple nodes.
- Data is distributed among several nodes based on a hash slot, and data distribution can be adjusted dynamically.
- Scalability: Add and remove nodes in the cluster easily. Nodes can be added or removed dynamically, and the system can scale up to 1000 nodes.
- Automatic failover can be done by using Slave as a standby data copy. Because of supports the master-slave structure, you don’t need any additional failover handling, it has built-in failover of the master;

Redis Cluster Cons:
- You need at least 6 nodes — 3 master and slave
- Not entirely highly available, the cluster will stop down if the majority of masters are unavailable in the case of a bigger failure.
- Data is replicated asynchronously, and there is no guarantee of data consistency.
- Because the replication structure only allows one layer, the slave node can only duplicate the master node.
- Because data is sharded among the masters, clients should have network access to all nodes in a Redis Cluster. If a client wants to write data to Master1 but the data belongs to Master2, Master1 will give the client a MOVE message, directing it to forward the request to Master2.
- Not every library supports; the lack of client library implementations in Redis Cluster.
- It is not possible to ensure a strong consistency. In practice, this means that Redis Cluster may lose writes that were acknowledged by the system to the client under certain circumstances.
- Because of data partitioning, data handling becomes more complicated; for example, you should handle multiple RDB / AOF files, and you need to aggregate the persistence files from multiple instances and hosts to generate a backup of your data. It is not possible to manage backups from a single location.


Hiç yorum yok:

Yorum Gönder