Analysis of the mainstream architecture scheme of Redis cluster

Source: Internet
Author: User
Tags documentation failover hash redis redis cluster
Little yards of a small-size farm in Iraq 2017-02-10 09:29

Redis is widely used in Internet big data platform to cache hotspot data, avoid massive requests to overwhelm database, and improve the response speed and concurrency of service nodes. With the increase in data volume, because Redis is a single physical machine or virtual machine memory, memory resources are limited, to dynamically expand the shrinkage, you need to use the Redis cluster. The architecture of the Redis cluster has undergone a series of evolutionary and improved processes, and this article introduces four major Redis architecture schemes.
Client Shard

Advantages

Without the use of third-party middleware, the implementation methods and code are self-controlling and can be adjusted at any time. This shard performance is better than proxy (because there is less distribution), distribution pressure on the client, no service side pressure increase

Disadvantages

Can not smooth horizontal expansion, expansion/contraction, you must manually adjust the Shard program, failure can not automatically transfer, difficult to transport Twemproxy

Advantages

Low cost of operation and maintenance. Business parties do not care about back-end Redis instances as they do with Redis. The logical and stored logic of a Proxy is isolated

Disadvantages

A. The agent layer has more than one forwarding, performance loss

B. When expanding/shrinking, some data may be invalidated, manual migration required, high operational requirements, and difficult to achieve a smooth scaling capacity

C. Malfunction, cannot be transferred automatically, operation dimension is poor Redis Cluster

Advantages

A. No center node

B. Data is distributed across multiple Redis instances by Slot storage

C. Smooth expansion/shrinking nodes

D. Automatic failover (exchange of status information between nodes via GOSSIP protocol, polling mechanism completed Slave to Master Corner

Color enhancement)

E. Reduced operation and maintenance costs, improved scalability and high availability of the system

Disadvantages

A. Heavy reliance on external redis-trib

B. Lack of monitoring management

C. Need to rely on Smart Client (connection maintenance, cache routing table, MULTIOP and Pipeline support)

D. Failover node detection is too slow, rather than "central node ZooKeeper" timely

E. Overhead of GOSSIP messages

F. Inability to differentiate hot and cold data based on statistics

G. Slave "cold standby", can not relieve the reading pressure Proxy + Redis Cluster

Advantages

Smart Client:

A. Compared to the use of agents, reduce the consumption of a layer of network transmission, high efficiency.

B. Do not rely on third-party middleware, the implementation methods and code of their own control, can be adjusted at any time.

Proxy:

A. Provide a set of HTTP Restful interfaces to isolate the underlying storage. Fully transparent to the client, called across languages.

B. Upgrading maintenance is easier and maintaining Redis Cluster requires only a smooth upgrade Proxy.

C. Hierarchical storage, the underlying storage to do hot and cold heterogeneous storage.

D. Permission control, Proxy can be controlled by the secret key whitelist, some illegal requests are filtered out. And

It can also control the large Value that the user requests, and filter.

E. Security, you can block out some dangerous commands, such as Keys, Save, Flush all, and so on.

F. Capacity control, capacity limits based on different user capacity requests.

G. Resource logical isolation, based on the different user's Key prefix, for resource isolation.

H. Monitoring of buried points, for different interfaces to the monitoring of buried point and other information.

Disadvantages

Smart Client:

A. The client's immaturity, affects the application stability, enhances the development difficulty.

B. Multiop and Pipeline support are limited.

C. Connection maintenance, the Smart client maintains the Socket for each node connected to the cluster.

Proxy:

A. The agent layer has more than one forwarding, performance loss.

b The expansion/contraction time for the operation and maintenance requirements, and it is difficult to achieve a smooth expansion of the actual project of how to choose it.

The following are the words in the Redis official documentation:

The REDIS-CLI cluster support was very basic so it always uses the fact that Redis cluster nodes be able to redirect a CLI ENT to the right node. A serious client is able to does better than that, and caches the map between hash slots and nodes addresses, to directly use The right connection to the right node. The map is refreshed if something changed in the cluster configuration, for example after a failover or after the S Ystem Administrator changed the cluster layout by adding or removing nodes.

The main idea is that the current Redis cluster official client functionality is rudimentary and relies on Redis node redirection to the Redis instance where the data resides in the cluster. There is a need for a more sophisticated client that enables consistent hash,failover and cluster management capabilities. So using the official Redis cluster client is not a sensible choice, this article provides 3 kinds of programs for everyone to refer to, if there are unreasonable places, welcome everyone to discuss with me.

Scenario 1 using nginx development (openresty mode)

The reasons are as follows

A. Single-Master multi-work mode, each work is a single-process one-thread mode like Redis, and is a base

In the Epoll event-driven mode.

B. Nginx uses an asynchronous, non-blocking way to handle requests, an efficient asynchronous framework.

C. Memory consumption, has its own set of memory pool management mode. A large number of small memory applications can be aggregated to

Malloc faster. Reduce memory fragmentation and prevent memory leaks. Reduce the complexity of memory management.

D. In order to improve the access speed of Nginx, Nginx uses its own set of connection pool.

E. Most importantly, support for custom module development.

F. In the industry, the word of mouth of Nginx,redis can be regarded as two great artifacts. There is no mention of performance.

Scenario 2 Codis (Agent-based Redis cluster scheme with pea pods)

Reference Codis Official documentation Https://github.com/CodisLabs/codis

Codis is a complete set of caching solutions, including high availability, data fragmentation, monitoring, dynamic spread, etc...

Go is apps-> agent->redis cluster, a certain scale after the basic use of this way.

Scenario 3 self-developed Redis smart client independently

The main implementation of REDIS slots management, failover, consistent hash function.

The above is the author in the actual work summary and research results, capacity limits, if you have other suggestions and good ideas, welcome to my message to discuss. This headline is updated every day with Internet-related technology sharing, please subscribe.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.