当前位置:网站首页>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
边栏推荐
- 基础SQL教程
- 5-1 blocking / non blocking, synchronous / asynchronous
- Yolov5 advanced seven target tracking latest environment construction (II)
- 4-20-4-23 concurrent server, TCP state transition;
- ASTC texture compression (adaptive scalable texture compression)
- Global and Chinese markets for flexible chips 2022-2028: Research Report on technology, participants, trends, market size and share
- 【Transform】【NLP】首次提出Transformer,Google Brain团队2017年论文《Attention is all you need》
- . Net six design principles personal vernacular understanding, please correct if there is any error
- [engine development] rendering architecture and advanced graphics programming
- 什么是embedding(把物体编码为一个低维稠密向量),pytorch中nn.Embedding原理及使用
猜你喜欢
[engine development] rendering architecture and advanced graphics programming
Pytorch深度学习和目标检测实战笔记
基础SQL教程
Introduction to opengl4.0 tutorial computing shaders
5.2-5.3
4-33--4-35
复合类型(自定义类型)
Functional modules and application scenarios covered by the productization of user portraits
Byte practice plane longitude 2
The picture quality has been improved! LR enhancement details_ Lightroom turns on AI photo detail enhancement: picture clarity increases by 30%
随机推荐
[ue4] material and shader permutation
Global and Chinese market of transfer case 2022-2028: Research Report on technology, participants, trends, market size and share
[ue4] cascading shadow CSM
There are links in the linked list. Can you walk three steps faster or slower
"Seven weapons" in the "treasure chest" of machine learning: Zhou Zhihua leads the publication of the new book "machine learning theory guide"
Rasterization: a practical implementation (2)
Tensor 省略号(三个点)切片
Leetcode the smallest number of the rotation array of the offer of the sword (11)
[transform] [NLP] first proposed transformer. The 2017 paper "attention is all you need" by Google brain team
Remote server background hangs nohup
Leetcode sword offer find the number I (nine) in the sorted array
NOI OPENJUDGE 1.3(06)
【pytorch学习笔记】Transforms
5.4-5.5
什么是one-hot encoding?Pytorch中,将label变成one hot编码的两种方式
Global and Chinese market of trimethylamine 2022-2028: Research Report on technology, participants, trends, market size and share
Center and drag linked global and Chinese markets 2022-2028: Research Report on technology, participants, trends, market size and share
5-1 blocking / non blocking, synchronous / asynchronous
[engine development] rendering architecture and advanced graphics programming
Global and Chinese market of optical fiber connectors 2022-2028: Research Report on technology, participants, trends, market size and share