当前位置:网站首页>redis单线程问题强制梳理门外汉扫盲
redis单线程问题强制梳理门外汉扫盲
2022-07-03 15:05:00 【小姐姐修灯泡吗】
1.很多人说到Redis单线程性能很高,被问到Redis是不是单线程的,就答是的。摸着脚板想,怎么可能一个Redis服务就一个线程在工作呢。不懂就要问,那怎么回事呢
Redis单线程是指Redis的网络IO和读写过程是由一个线程来完成的,而这部风使我们业务最关心的地方,也就是Redis对外提供键值存储的最主要流程,所以称之为单线程。
但是Redis的其他功能,数据持久化AOF或者RDB,异步删除数据,集群同步数据都是由额外的线程来处理的。
2.Redis单线程为什么还能那么快?
解释很简单,Redis的所有数据都是在内存中,你关系型数据库都在磁盘上,读取速度更本就不是一个数量级,你说他快不快。还有一点就是单线程避免了多线程的致命问题,那就是上线文切换,假如是多线程设计,我内存读写速度杠杠的,假如我读取一个键值是1纳秒,结果你切换一次上下线文都需要10毫秒,你是不是有病,我TM去银行办理查询存款,你告诉我等到给我开户的经理来才能给我查,30米的大刀就放在你身边,就问你拔不拔刀。
3.Redis如何单线程处理那么多的并发客户端连接?
Redis的IO多路复用,Redis利用epoll来实现IO多路复用,将连接信息和时间放到队列中,然后依次交给事件分发处理器处理。可以在Redis的redis.config中查看最大的连接数
命令:config get maxclients
边栏推荐
- C language dup2 function
- [opengl] pre bake using computational shaders
- Devaxpress: range selection control rangecontrol uses
- [pytorch learning notes] datasets and dataloaders
- 什么是embedding(把物体编码为一个低维稠密向量),pytorch中nn.Embedding原理及使用
- Vs+qt application development, set software icon icon
- Influxdb2 sources add data sources
- Adobe Premiere Pro 15.4 has been released. It natively supports Apple M1 and adds the function of speech to text
- 官网MapReduce实例代码详细批注
- [graphics] real shading in Unreal Engine 4
猜你喜欢
![[set theory] inclusion exclusion principle (complex example)](/img/9a/db5a75e27516378c31531773a8a221.jpg)
[set theory] inclusion exclusion principle (complex example)

运维体系的构建

5.2-5.3

High quality workplace human beings must use software to recommend, and you certainly don't know the last one

Yolov5系列(一)——网络可视化工具netron

解决pushgateway数据多次推送会覆盖的问题
![[Yu Yue education] scientific computing and MATLAB language reference materials of Central South University](/img/83/922efb4f88843f1b7feaccf2b515b9.jpg)
[Yu Yue education] scientific computing and MATLAB language reference materials of Central South University

【可能是全中文网最全】pushgateway入门笔记

基础SQL教程

B2020 分糖果
随机推荐
B2020 分糖果
TPS61170QDRVRQ1
How can entrepreneurial teams implement agile testing to improve quality and efficiency? Voice network developer entrepreneurship lecture Vol.03
链表有环,快慢指针走3步可以吗
Rasterization: a practical implementation (2)
406. Reconstruct the queue according to height
Awvs batch operation script
NOI OPENJUDGE 1.3(06)
My QT learning path -- how qdatetimeedit is empty
Global and Chinese markets of AC electromechanical relays 2022-2028: Research Report on technology, participants, trends, market size and share
【微信小程序】WXSS 模板样式
What is embedding (encoding an object into a low dimensional dense vector), NN in pytorch Principle and application of embedding
Center and drag linked global and Chinese markets 2022-2028: Research Report on technology, participants, trends, market size and share
CentOS7部署哨兵Redis(带架构图,清晰易懂)
Qt development - scrolling digital selector commonly used in embedded system
什么是Label encoding?one-hot encoding ,label encoding两种编码该如何区分和使用?
cpu飙升排查方法
Global and Chinese market of lighting control components 2022-2028: Research Report on technology, participants, trends, market size and share
基础SQL教程
Besides lying flat, what else can a 27 year old do in life?