Cluster solution of redis practice

Source: Internet
Author: User
Tags redis cluster

This article original from the http://blog.csdn.net/voipmaker reprint indicate the source.

The purpose of the redis cluster is to achieve horizontal data scaling. By storing a piece of data in multiple machines, the database size, bandwidth, and computing capacity can be scaled horizontally.

 

There are roughly three data sharding (cluster) methods:

 

(1) implement data sharding on the client

That is, the machine on which the client should store and find the data key. The advantage of this method is that it reduces the complexity of the server cluster. When the client implements data sharding, the server is independent, the server has no association before. Most redis client libraries implement this function, also known as sharding. The disadvantage of this method is that the client needs to know the contact information of the current cluster node in real time,

When a new node is added, the client must support dynamic sharding. Most clients do not support this function and need to restart redis. Another drawback is that the HA of redis requires additional consideration.

 

(2) implement data sharding on the server

The theory is that the client communicates with any node in the cluster at will. The server is responsible for calculating the machine on which a key is located. When the client accesses a machine, the server calculates the machine on which the corresponding key should be stored and returns the result to the client. The client then operates the key on the corresponding node. This is a redirection process, which is implemented by redis3.0, currently in beta version, redis 3.0 clusters support the HA function at the same time. When a master node fails, its slave will automatically take over.

Server-side cluster implementation requires the client language to implement the server cluster protocol. Currently, most Java, PHP, and Ruby clients have the redis-cluster client implementation version.

 

(3) implement data sharding through the Proxy Server

 

This method uses a proxy server to implement data sharding. The client directly contacts the proxy. The proxy calculates the cluster node information and sends the request to the corresponding cluster node. This reduces the complexity of the client and requires proxy to collect cluster node information. Twemproxy is an open-source Twitter proxy that implements this function. This method adds a proxy between the client and the server,

However, this method was officially recommended before the stable version of redis 3.0 was released. Combined with the HA solution of redis-Sentinel, it is a good combination.

Cluster solution of redis practice

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.