Home> Database> Redis> body text

Why do you need Redis partitioning? What are the implementation options?

青灯夜游
Release: 2021-12-20 10:01:42
forward
2883 people have browsed it

This article will take you to understand Redis partitioning, introduce why Redis partitioning is needed, the implementation plan of Redis partitioning, and the shortcomings of Redis partitioning. I hope it will be helpful to everyone!

Why do you need Redis partitioning? What are the implementation options?

Redis is single-threaded. How to improve the utilization of multi-core CPU?

You can deploy multiple Redis instances on the same server and use them as different servers. At some point, one server is not enough anyway, so, If you want to use multiple CPUs, you can consider sharding. [Related recommendations:Redis Video Tutorial]

Why do we need to partition Redis?

Partitioning allows Redis to manage larger memory, and Redis will be able to use the memory of all machines. Without partitions, you can only use up to one machine's memory. Partitioning allows Redis's computing power to be doubled by simply adding computers, and Redis's network bandwidth will also increase exponentially with the addition of computers and network cards.

What are the Redis partition implementation solutions?

1. Client partitioning means that the client has decided which redis node the data will be stored in or read from. Most clients already implement client-side partitioning.

2. Agent partitioning means that the client sends the request to the agent, and then the agent decides which node to go to to write or read data. The agent decides which Redis instances to request based on partition rules, and then returns them to the client based on the Redis response results. A proxy implementation for redis and memcached is Twemproxy.

3. Query routing (Query routing) means that the client randomly requests any redis instance, and then Redis forwards the request to the correct Redis node. Redis Cluster implements a hybrid form of query routing, but instead of forwarding requests directly from one redis node to another redis node, it redirects directly to the correct redis node with the help of the client.

What are the disadvantages of Redis partitioning?

1. Operations involving multiple keys are usually not supported. For example, you cannot intersect two collections because they may be stored in different Redis instances (actually there is a way for this situation, but the intersection command cannot be used directly).

2. If multiple keys are operated at the same time, Redis transactions cannot be used.

3. The partitioning granularity is the key, so it is not possible to shard a dataset with a single huge key like a very big sorted set)

4. When using partitions, data processing will be very complicated. For example, for backup, you must collect RDB/AOF files from different Redis instances and hosts at the same time.

5. Dynamic expansion or contraction during partitioning may be very complicated. Redis cluster adds or deletes Redis nodes at runtime, which can achieve data rebalancing that is transparent to users to the greatest extent. However, some other client partitioning or proxy partitioning methods do not support this feature. However, there is a pre-sharding technology that can also solve this problem better.

For more programming related knowledge, please visit:Programming Video! !

The above is the detailed content of Why do you need Redis partitioning? What are the implementation options?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:juejin.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!