Home  >  Article  >  Database  >  The difference between redis cluster and distributed

The difference between redis cluster and distributed

(*-*)浩
(*-*)浩Original
2019-11-22 14:24:474054browse

The difference between redis cluster and distributed

Distribution refers to splitting the business system, that is, each distributed node implements different functions.

A cluster is a group of service entities that work together to provide a service platform that is more scalable and available than a single service entity. (Recommended learning: Redis Video Tutorial)

Simply put, distribution improves efficiency by shortening the execution time of a single task, while clustering improves efficiency by shortening the execution time of a single task. The number of tasks executed per unit time to improve efficiency.

Redis Cluster cluster mode usually has the characteristics of high availability, scalability, distribution, fault tolerance and other characteristics. There are generally two Redis distributed solutions:

Client partition scheme

The client has already decided which redis node the data will be stored in or read from. Get data. The main idea is to use a hash algorithm to hash the key of Redis data. Through the hash function, a specific key will be mapped to a specific Redis node.

The representative of the client partitioning scheme is Redis Sharding. Redis Sharding is a Redis multi-instance cluster method commonly used in the industry before Redis Cluster came out. Java's Redis client driver library Jedis supports the Redis Sharding function, namely ShardedJedis and ShardedJedisPool combined with the cache pool.

Advantages

No third-party middleware is used, the partitioning logic is controllable, the configuration is simple, there is no correlation between nodes, easy linear expansion, and strong flexibility.

Disadvantages

The client cannot dynamically add or delete service nodes. The client needs to maintain the distribution logic by itself. There is no connection sharing between clients, which will cause waste of connections.

Proxy partitioning scheme

The client sends a request to a proxy component, the proxy parses the client's data, forwards the request to the correct node, and finally replies the result to client.

Advantages: Simplified client distributed logic, transparent client access, low switching costs, and separation of proxy forwarding and storage. Disadvantages: There is an additional proxy layer, which increases the complexity of architecture deployment and performance loss.

The mainstream implementation solutions for proxy partitioning include Twemproxy and Codis.

Twemproxy

Twemproxy, also called nutcraker, is an open source intermediate proxy server program for redis and memcache by twitter. As a proxy, Twemproxy can accept access from multiple programs, forward it to various Redis servers in the background according to routing rules, and then return to the original route. Twemproxy has a single point of failure problem and needs to be combined with Lvs and Keepalived to create a high-availability solution.

Advantages: wide application range, high stability, and high availability of the intermediate proxy layer. Disadvantages: Inability to smoothly expand/shrink horizontally, no visual management interface, unfriendly operation and maintenance, failure to automatically transfer.

Codis

Codis is a distributed Redis solution. For upper-layer applications, there is no difference between connecting to Codis-Proxy and directly connecting to the native Redis-Server. The bottom layer of Codis will handle the forwarding of requests and perform data migration and other tasks without downtime. Codis uses a stateless proxy layer, and everything is transparent to the client.

Advantages

Implements high availability, data sharding and automatic balancing of the upper Proxy and underlying Redis, provides command line interface and RESTful API, and provides monitoring and management interfaces , Redis nodes can be added and deleted dynamically.

Disadvantages

The deployment architecture and configuration are complicated, it does not support cross-machine rooms and multi-tenants, and it does not support authentication management.

For more Redis-related technical articles, please visit the Introduction to Using Redis Database Tutorial column to learn!

The above is the detailed content of The difference between redis cluster and distributed. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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