当前位置:网站首页>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
边栏推荐
- Yolov5进阶之八 高低版本格式转换问题
- SQL server安装位置改不了
- 从书本《皮囊》摘录的几个句子
- 【Transform】【NLP】首次提出Transformer,Google Brain团队2017年论文《Attention is all you need》
- The picture quality has been improved! LR enhancement details_ Lightroom turns on AI photo detail enhancement: picture clarity increases by 30%
- Vs+qt application development, set software icon icon
- Besides lying flat, what else can a 27 year old do in life?
- [pytorch learning notes] transforms
- Simulation of LS -al command in C language
- .NET六大设计原则个人白话理解,有误请大神指正
猜你喜欢
CentOS7部署哨兵Redis(带架构图,清晰易懂)
What is embedding (encoding an object into a low dimensional dense vector), NN in pytorch Principle and application of embedding
5.2-5.3
[ue4] Niagara's indirect draw
Unity hierarchical bounding box AABB tree
Rasterization: a practical implementation (2)
The picture quality has been improved! LR enhancement details_ Lightroom turns on AI photo detail enhancement: picture clarity increases by 30%
Byte practice surface longitude
[transformer] Introduction - the original author of Harvard NLP presented the annotated transformer in the form of line by line implementation in early 2018
运维体系的构建
随机推荐
[attention mechanism] [first vit] Detr, end to end object detection with transformers the main components of the network are CNN and transformer
[graphics] hair simulation in tressfx
[opengl] face pinching system
cpu飙升排查方法
How can entrepreneurial teams implement agile testing to improve quality and efficiency? Voice network developer entrepreneurship lecture Vol.03
4-33--4-35
Global and Chinese market of lighting control components 2022-2028: Research Report on technology, participants, trends, market size and share
Global and Chinese market of marketing automation 2022-2028: Research Report on technology, participants, trends, market size and share
【可能是全中文网最全】pushgateway入门笔记
Fundamentals of PHP deserialization
Class part2
How to color ordinary landscape photos, PS tutorial
Using notepad++ to build an arbitrary language development environment
App全局异常捕获
第04章_逻辑架构
Mmdetection learning rate and batch_ Size relationship
Série yolov5 (i) - - netron, un outil de visualisation de réseau
.NET六大设计原则个人白话理解,有误请大神指正
QT - draw something else
[combinatorics] permutation and combination (set permutation, step-by-step processing example)