Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the characteristics of Redis Sharding cluster

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

This article will explain the characteristics of Redis Sharding cluster for you in detail. The content of the article is of high quality, so the editor will share it with you for reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.

Redis Sharding cluster

Redis 3 officially launched the official cluster technology to solve the problem of collaborative service for multiple Redis instances. Redis Cluster can be said to be the embodiment of server-side Sharding sharding technology, that is, the key value is reasonably assigned to each instance shard according to a certain algorithm, and each instance node coordinates and communicates together to undertake consistent services.

Multi-Redis instance service is much more complex than a single Redis instance, which involves technical problems such as location, collaboration, fault tolerance, capacity expansion and so on. Here, we introduce a lightweight client-side Redis Sharding technology.

Redis Sharding can be said to be a multi-Redis instance clustering method commonly used in the industry before Redis Cluster came out. The main idea is to use the hash algorithm to hash the key of Redis data. Through the hash function, a specific key will be mapped to a specific Redis node. In this way, the client knows which Redis node to manipulate the data to.

Fortunately, the java redis client drives jedis and already supports the Redis Sharding feature, namely ShardedJedis and ShardedJedisPool combined with cache pools.

The Redis Sharding implementation of Jedis has the following characteristics:

The consistent hash algorithm (consistent hashing) is used to hashing key and node name at the same time, and then map and match. The algorithm is MURMUR_HASH.

The main reason for using a consistent hash instead of a simple similar hash module mapping is that when nodes are added or decreased, there is no rehashing caused by rematching. The consistent hash only affects the key allocation of neighboring nodes, and the impact is small.

In order to avoid the pressure of node allocation caused by consistent hashing only affecting neighboring nodes, ShardedJedis will virtualize 160 virtual nodes to hash each Redis node according to its name (no, Jedis will give it a default name).

According to the weight weight, 160x virtual nodes can also be virtualized. By mapping and matching with virtual nodes, when adding or decreasing Redis nodes, key can be moved and redistributed more evenly among Redis nodes, rather than only neighboring nodes are affected.

ShardedJedis supports the keyTagPattern pattern, that is, a part of the keyTag of the key is extracted as sharding, so that a set of associated key can be put into the same Redis node by reasonably naming the key, which is important to avoid accessing related data across nodes.

On the characteristics of Redis Sharding cluster to share here, I hope that the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report