当前位置:网站首页>Redis pipeline technology / partition
Redis pipeline technology / partition
2022-07-25 00:36:00 【Hua Weiyun】
Redis Pipeline technology
Redis Is a client based - Server models and requests / In response to the protocol TCP service . This means that the request will usually follow the following steps :
The client sends a query request to the server , And listen for socket returns , Usually in blocking mode , Wait for the server to respond .
The server processes the command and returns the result to the client .
Redis Pipeline technology allows the client to continue sending requests to the server when the server does not respond , Read the responses of all servers for the last time .
example
To see redis The Conduit , Just start redis Instance and enter the following command :
$(echo -en "PING\r\n SET runoobkey redis\r\nGET runoobkey\r\nINCR visitor\r\nINCR visitor\r\nINCR visitor\r\n"; sleep 10) | nc localhost 6379+PONG+OKredis:1:2:3 In the example above , We use ping Command check redis Is the service available . Then we will runoobkey Is set to redis, And then we get runoobkey Value , And automatically triple the number of visitors .
In the returned results , We can see that these commands are submitted to redis service , Read the responses of all servers for the last time
The most significant advantage of pipeline technology is to improve redis Service performance .
Some test data
require 'rubygems' require 'redis'def bench(descr) start = Time.now yield puts "#{descr} #{Time.now-start} seconds" enddef without_pipelining r = Redis.new 10000.times { r.ping } enddef with_pipelining r = Redis.new r.pipelined { 10000.times { r.ping } } endbench("without pipelining") { without_pipelining } bench("with pipelining") { with_pipelining } In the next test , We will use redis Of Ruby Client to support the characteristics of Pipeline Technology , And test the speed-up effect of assembly line technology .
In LAN Mac OS X The data of the above simple script executed on the system shows , After opening the pipeline , Round trip latency has improved significantly .
Redis
Partitioning is to divide data into multiple redis The process of example , Therefore, each instance only saves a subset of the key .
The advantages of zoning
By using the total memory of multiple computers , We can build a larger database .
Through multiple cores and computers , We can expand our computing power ; Through multiple computers and network adapters , We can expand the network bandwidth .
Insufficient partitions
redis Some functions of the do not perform well in partitioning :
Typically, multiple key operations are not supported . for example , When two sets map to different redis When an instance , You cannot perform an intersection operation on these two sets .
Cannot use multiple keys Redis Business .
When using partitions , Data processing is more complex . for example , You need to deal with multiple rdb/aof file , And back up persistent files from multiple instances and hosts .
Adding or removing capacity is also complex . majority redis The cluster supports transparent data balancing for adding and deleting nodes at run time , But other systems ( Such as client partition and proxy ) This feature is not supported . However , A technique called pre hardening is helpful .
Partition type
Redis There are two types of divisions . Suppose there are four redis example R0、R1、R2、R3 And multiple keys represent the user , for example user:1 and user:2. For a given key , There are many different ways to choose which instance the key is stored in . let me put it another way , There are different systems that map keys to redis service .
Range partitioning
The simplest way to partition is by range , Mapping objects in a specific range to specific redis example .
for example ,ID by 0 To 10000 The user of will be saved to the instance R0,ID by 10001 To 20000 Users of will be saved to R1, And so on .
This method is feasible , It can be used in practice . The disadvantage is that there is a mapping table from interval range to instance . This table needs to be managed . meanwhile , It also requires mapping tables for various objects , It's not usually redis Good way .
Hash partition
Another partitioning method is hash partitioning . This applies to any key , And it doesn't need to be an object name : This form is as simple as the following description :
Use the hash function to convert the key to a number , for example , Use CRC32 hash function . Key in foobar On the implementation CRC32(foobar) Will output a similar 93024922 The integer of .
Take the modulus of this integer and convert it to 0 To 3 Number between , Then this integer can be mapped to four redis One example .93024922%4=2, This means that the key foobar It should be kept in R2 In the example . notes : Modular operation is the remainder of division , In many programming languages % Operator implementation .
边栏推荐
- C language force buckle the eleventh question to find the maximum capacity of the bucket. (two methods)
- Upload and download filask files
- [mindspore ascend] [running error] graph_ In mode, run the network to report an error
- Wechat applet development learning 5 (custom components)
- 7.24 party notice
- Pain and happiness -nio programming
- EF core: self referencing organizational structure tree
- mysql初次安装的root密码是什么
- Detailed explanation of the usage of vector, queue and stack
- How to use measurement data to drive the improvement of code review
猜你喜欢

动态规划-01背包滚动数组优化

SQL file import database - Nanny level tutorial

Use es to realize fuzzy search and search recommendation of personal blog
![[help] mindspire training based on ascend910 cannot reproduce the model effect on GPU](/img/b5/c02ef57526d208b02dfa00189e9ecb.jpg)
[help] mindspire training based on ascend910 cannot reproduce the model effect on GPU

This visual is not connected to the presentationsource.
![[acwing weekly rematch] 61st weekly 20220723](/img/8b/df2c8d516db1e7e5f2d50bcf62b2b1.png)
[acwing weekly rematch] 61st weekly 20220723

Detailed usage of iperf

Two numbers that appear only once in the array

C # "learning code snippet" - recursively obtain all files under the folder

Dynamic programming-01 knapsack rolling array optimization
随机推荐
Does opengauss support using Sqlalchemy connections?
R language uses ISNA function to check whether the list and dataframe contain missing values, marks abnormal values in data columns in dataframe as missing values Na, and uses na.omit function to dele
How to make five kinds of data structures in redis
Two numbers that appear only once in the array
Research and Multisim Simulation of linear circuit characteristics (engineering documents attached)
ROS manipulator movelt learning notes 3 | kinect360 camera (V1) related configuration
Pain and happiness -nio programming
Codeworks round 651 (Div. 2) ABCD solution
LeetCode_392_判断子序列
Soft test --- fundamentals of programming language (Part 2)
UART
2. Load test
LeetCode_ 392_ Judgement subsequence
痛并快乐的-NIO编程
[acwing weekly rematch] 61st weekly 20220723
Fast development board for Godson solid state drive startup (burning system to solid state) - partition
LeetCode_ 6124_ The first letter that appears twice
Log4j configuration file
进程的几种状态
The font changes with the change of the form