当前位置:网站首页>Redis6.0 new features (Part 2)
Redis6.0 new features (Part 2)
2022-06-22 02:56:00 【Java interview 365】
Redis6.0 New characteristics
Multithreading networks IO
When I saw this, my first reaction was , what ! Isn't it faster for a single thread ? To 6.0 Just fooling around ? Before Redis That's what the author said
because Redis Is a memory based operation ,CPU No Redis Bottleneck ,Redis The most likely bottleneck is the size of machine memory or network bandwidth . Since a single thread is easy to implement , and CPU Not a bottleneck , So it's natural to adopt a single thread solution
Let's think about a question first ,Redis What does single thread mean in ?
== The Internet IO And read / write operations of key value pairs ==, That is to say RDB File generation ,AOF File rewriting , Data deletion and so on are all asynchronous operations .
So why 6.0 The network needs to be IO Change to multithreading ?
Because with the improvement of network hardware ,Redis Performance bottlenecks may occur on the network IO On , That is to say, the processing speed of a single thread cannot keep up with that of the underlying network hardware .
6.0 Previous networks IO Handle
Here's a simple one RedisIO Processing order , Of course Redis Add multiplexing IO After the model , Relatively speaking, it is more complicated , Multiplexing will not be discussed here for the time being IO Model .

6.0 After the network IO Handle
6.0 After that, we mainly focus on the above two networks IO To optimize , Add multithreading , The process diagram is as follows

The logic of the process diagram may not be shown , So it can be seen in combination with the following flow chart

stay Redis6.0 Multithreading will not be enabled by default , We can do it in redis.conf The following commands are configured in the file , Enable multithreading
### Enable multithreading
io-threads-do-reads yes
When using multithreading, you also need to pay attention to a configuration
io-threads Number of threads
Redis The official pointed out that , Use multithreaded scenarios CPU The number of cores must reach 4 Supranuclear , If CPU yes 4 The number of threads recommended by the core official is set to 2-3, If CPU Auditing for 8 nucleus , Then the official recommended configuration 6 individual IO Threads , If you use more than 8 Threads will not significantly improve performance , in other words The number of threads should be less than that of the instance machine CPU Number of cores .
Fine grained permission control ACL
stay Redis6.0 Previously, we wanted to prohibit the execution of some commands in production, such as (KEYS、FLUSHDB、FLUSHALL wait ), Our solution can only be to adopt rename-command Command to rename a particular command , Avoid misoperation , How to achieve it ?
6.0 Previous command restrictions
find redis.conf The configuration file , We can do it in SECURITY Under module , Add the following configuration
### rename-command Old orders New command The following order is to KEYS Rename the command to TEST
rename-command KEYS TEST
Add the configuration , Restart the service after saving successfully
### The original command is not recognized , The new command succeeded
127.0.0.1:6379> keys *
(error) ERR unknown command `keys`, with args beginning with: `*`,
127.0.0.1:6379> test *
1) "name"
2) "age"
6.0 After that, permission control
Redis6.0 After that, the concept of user is mainly added , This is not available in the previous version , Depending on the user, you can bind permissions
### Create a test user , take test The user's password is set to test
127.0.0.1:6379> ACL SETUSER test on >test
OK
Enable or disable commands
### user test Enable hash Command and string command ( You can also specify the prefix of the operation key value ~name*)
ACL SETUSER test [email protected] [email protected]

Code demonstration
127.0.0.1:6379> keys *
1) "name2"
2) "age"
3) "name1"
4) "name"
### establish test user , Password plaintext is set to test, Operation only allowed name Key value at the beginning , All commands can be operated
127.0.0.1:6379> ACL SETUSER test on >test ~name* [email protected]
OK
### Authority verification , land test
127.0.0.1:6379> auth test test
OK
127.0.0.1:6379> get name
"2"
### test User get non name The key value at the beginning failed
127.0.0.1:6379> get age
(error) NOPERM this user has no permissions to access one of the keys used as arguments
127.0.0.1:6379> set name 2
OK
127.0.0.1:6379> set age 2
(error) NOPERM this user has no permissions to access one of the keys used as arguments
127.0.0.1:6379>
127.0.0.1:6379> DECR age
(error) NOPERM this user has no permissions to access one of the keys used as arguments
边栏推荐
- C mapster object mapper learning
- Microblog closes publishing multiple part-time fraud information illegal accounts: how to crack down on data fraud
- Database daily question - day 19: top ranked travelers
- GetEmptyBlcoksPre Info
- tag动态规划-刷题预备知识-1.动态规划五部曲解题法 + lt.509. 斐波那契数/ 剑指Offer 10.I + lt.70. 爬楼梯彻底解惑 + 面试真题扩展
- Select for i/0 multiplexing
- Anaconda historical version download
- Day13QMainWindow2021-09-28
- Implementation principle and application practice of Flink CDC mongodb connector
- An article thoroughly learns to draw data flow diagrams
猜你喜欢
随机推荐
图数据平台解决方案:集群部署
PMP pre exam guide on June 25, you need to do these well
Day21qt mouse event 2021-11-01
[pit encountered in docekr learning]
C1-qt idea of realizing simple calculator 2021.10.15
图像元数据(Metadata)获取与修改
Select for i/0 multiplexing
【Percona-Toolkit】系列之pt-table-checksum和pt-table-sync 数据校验修复神器
【3.整数与浮点数二分】
Graphacademy course explanation: Fundamentals of neo4j graph data science
ATM simulation system
How to select the appropriate version of neo4j (version 2022)
Write your own kubernetes controller
Neo4j 技能树正式发布,助你轻松掌握Neo4j图数据库
交通标志分类
Force buckle 142 Circular linked list II
C++ primer Chapter 2 summary of variables and basic types
Conference chat room - development documents
UnionPay payment return merchant nignx post request 405
Sword finger offer 37 Serialized binary tree









