Advanced features (a) Redis study notes --- Redis of

Foreword

Before understanding Redis associated with advanced features, we must first understand a single issue Redis station may be encountered in the development, and related bottlenecks.

A problem that may be encountered

In general, to apply Redis projects, only one Redis is totally unacceptable for the following reasons:
[1] from the structure, a single server Redis single point of failure, and a server needs to handle all It requests load pressure. (Fault tolerance)
[2] from the capacity, single Redis server memory capacity is limited, even if the server is a content volume of Redis 256G, nor can the contents of all memory storage Redis used, in general, the largest single use of memory is not Redis it should be more than 20G.

II. Basic Overview

2.1 High Availability

"High availability" is usually used to describe a specially designed system, reducing downtime, while maintaining high availability of their services. (I have been able to use)

2.2 high concurrency

High concurrency Internet is one of the factors in the distributed system architecture design must be considered, it usually means that can simultaneously handle many concurrent requests through the design assurance system.
Some commonly used in high concurrency-related indicators have response time, throughput, queries per second rate, concurrent users, etc.

Response Time: system time response to requests, for example, a system for processing HTTP requests needs to 200ms, 200ms is the response time of the system call
throughput: number of requests processed per unit time
query rate per second (QPS): in response to requests per second number, in the Internet field, this indicator does not distinguish between throughput and less obvious.
Concurrent users: the number of users while carrying the normal use of the system functions. For example, an instant communication system, and represents a system of concurrent users online amount to some extent.

2.3 Method and improve system performance

Improve system concurrency manner, there are two main methodology: a vertical extension (Scale Up) from the horizontal expansion
vertical expansion: single server scalability
horizontal scaling: as long as the increase in the number of servers, system performance can be linearly extended, horizontal expansion of system architecture design is required, the difficulty is: how each layer horizontally scalable design in architecture.

Three. Redis master-slave replication

In the above we learned that a single bottleneck Redis server to use, as well as modern Internet development in the pursuit of high availability and high concurrency. Redis also introduced a way to solve this bottleneck and to adapt to this scenario ---- master-slave replication

3.1 Introduction

Scenario: merchandise on e-commerce sites, usually once uploaded, numerous views of that professional point of which is "read write less."
Master-slave replication: a Redis service can have multiple copies of the service, this service is called Redis Master, the other called Slaves.
Here Insert Picture Description
As shown in the figure, we will a Redis server as the primary repository (Masrer), as the other three from the library (Slave), the main library is only responsible for writing data, each data update will update the data synchronized to it all from the library, and the library is only responsible for reading data from, this way, there are two advantages:
[1] separate read and write, not only can increase the load capacity of the server, and are free to increase or decrease depending on the size of the request from how much the number of libraries.
[2] The data is copied several became good, even if there is a machine fails, you can also use data from other machines fast recovery.
Note that: in Redis master-slave mode, a master library can have more than one from the library, but that can only belong to one main library from the library.

3.2 Redis master-slave configuration

In Redis in order to achieve master-slave replication architecture is very simple, just add to the database from the configuration file in the following command.
[1] does not require any primary database configuration. Creating a database from

 ./bin/redis-server  ./redis.conf  --port 6380  --slaveof 127.0.0.1  6379 

Analytical parameters:
- Port from 6380 // server port number (the port number can define your own)
-slaveof 127.0.0.1 6379 // specify a primary server
plus slaveof parameters to start another instance of Redis as from the library, and listen 6380 port
[2] logged on to the server from the client (query functions from the server only)

./bin/redis-cli -p 6380 -a guoweixin      # 其中6380使我们自定义的从服务器的端口号, guoweixin是我们设置的Redis密码
变回主:slaveof on one  //不是任何从
变回从:slaveof  ip地址  端口号
Published 58 original articles · won praise 2 · Views 4464

Guess you like

Origin blog.csdn.net/TheWindOfSon/article/details/104642170