当前位置:网站首页>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
边栏推荐
- Remote server background hangs nohup
- Global and Chinese market of postal automation systems 2022-2028: Research Report on technology, participants, trends, market size and share
- 4-33--4-35
- 官网MapReduce实例代码详细批注
- Byte practice surface longitude
- [graphics] hair simulation in tressfx
- [opengl] face pinching system
- NOI OPENJUDGE 1.3(06)
- C language DUP function
- 【pytorch学习笔记】Transforms
猜你喜欢

解决pushgateway数据多次推送会覆盖的问题

PS tips - draw green earth with a brush

Composite type (custom type)

Zero copy underlying analysis

5.4-5.5

【Transform】【NLP】首次提出Transformer,Google Brain团队2017年论文《Attention is all you need》

基础SQL教程

Centos7 deployment sentry redis (with architecture diagram, clear and easy to understand)

Pytoch deep learning and target detection practice notes

Remote server background hangs nohup
随机推荐
【微信小程序】WXSS 模板样式
406. 根据身高重建队列
Search in the two-dimensional array of leetcode sword offer (10)
[graphics] efficient target deformation animation based on OpenGL es 3.0
Global and Chinese market of trimethylamine 2022-2028: Research Report on technology, participants, trends, market size and share
Global and Chinese markets of AC electromechanical relays 2022-2028: Research Report on technology, participants, trends, market size and share
什么是one-hot encoding?Pytorch中,将label变成one hot编码的两种方式
B2020 分糖果
[attention mechanism] [first vit] Detr, end to end object detection with transformers the main components of the network are CNN and transformer
解决pushgateway数据多次推送会覆盖的问题
"Seven weapons" in the "treasure chest" of machine learning: Zhou Zhihua leads the publication of the new book "machine learning theory guide"
Centos7 deployment sentry redis (with architecture diagram, clear and easy to understand)
Global and Chinese markets for infrared solutions (for industrial, civil, national defense and security applications) 2022-2028: Research Report on technology, participants, trends, market size and sh
el-switch 赋值后状态不变化
Awvs batch operation script
There are links in the linked list. Can you walk three steps faster or slower
How can entrepreneurial teams implement agile testing to improve quality and efficiency? Voice network developer entrepreneurship lecture Vol.03
[ue4] material and shader permutation
QT program font becomes larger on computers with different resolutions, overflowing controls
第04章_逻辑架构