当前位置:网站首页>快速了解服务器IO的实现
快速了解服务器IO的实现
2022-06-09 20:44:00 【w_rcss】
①单线程处理所有请求:通过while(true)循环
缺点:等待IO的阶段浪费大量cpu资源,cpu性能浪费。
解决思路 :增加线程并发,充分利用cpu资源。
②使用单独线程处理IO操作:一个连接建立后,通过new Thread执行具体的IO操作。
优点:相比①充分利用了cpu资源。
缺点:连接过多会造成线程过多,多线程竞争引起上下文切换开销。
解决思路:通过使用线程池合理有效控制线程数量。
③使用线程池处理IO操作:一个连接建立后,通过excutorService.submit()执行具体的IO操作。
优点:相比②减少了上下文切换开销。
④简单reactor模式:将多个channl注册到一个selector对象。
优点:通过一个线程监控多个请求,达到了多路复用。
缺点:当事件过多,读写操作的阻塞会影响对新连接的处理;读写和请求由一个线程处理(cpu浪费)。
⑤多reactor模式:Netty主要使用多reactor模式。一个主reactor监控连接请求,多个子reactor监控读写操作解决了阻塞对新连接的影响问题。每个reactor只包含一个selector对象,对应一个线程。一个请求channel的所有操作由一个线程解决避免了上下文切换的开销。
边栏推荐
- Jerry's modification video_ buf_ config. H application layer video buffer size [article]
- Extended application of C # static class
- 刚学嵌入式,想问问什么是中断,中断的概念是什么
- 加密狗驱动解决方案
- C language implementation of simple calculator
- c#逆序排序
- Drink at night, 50 classic SQL questions, really fragrant~
- Vite Lerna Monorepo 项目改造初体验
- C language to realize computer automatic shutdown program -- it can be used to spoof roommate's computer
- Go 调用 Kubernetes API 的 几个简单的 example
猜你喜欢

Figure guessing game in C language

Apple Announces Winner of the 2022 Apple Design Award

Export CSV file from neo4j diagram database

Cvpr2022 oral | cross view transformer for semantic segmentation of real-time map views

Neo4j桌面版数据库备份

HMI 联机下载失败的问题及解决方案

深夜小酌,50道经典SQL题,真香~

C language implementation of simple calculator

C language to realize computer automatic shutdown program -- it can be used to spoof roommate's computer
![[operation and maintenance department] ad domain file permission management](/img/f4/5598384b352b2335145ffa58437439.png)
[operation and maintenance department] ad domain file permission management
随机推荐
Edge browser setting network speed limit
C# For循环的一些小细节
Blog recommended | bookkeeper - Apache pulsar high availability / strong consistency / low latency storage implementation
Daily question - leecode59 (spiral matrix II)
深夜小酌,50道经典SQL题,真香~
VFP在64位win10环境下访问oracle出现的问题及解决方案
c#逆序排序
Kubernetes native cicd:tekton Hello World
Integer ordered array lookup -- traversal and half / bisection
Problems and solutions of VFP accessing Oracle under 64 bit win10 environment
C language to realize computer automatic shutdown program -- it can be used to spoof roommate's computer
Kubevirt network source code analysis (2)
KubeVirt网络源码分析(2)
ModelArts存储方案建议
C#中委托的应用
Chief architect of Huawei cloud stack: create a "hands-on" digital tool and answer the necessary topic of government enterprise IT digital transformation
做副业赚钱,这几个热门自媒体平台收益超多
Neo4j桌面版数据库备份
Deploy kubernetes + kubevirt and basic use of kubevirt
Parsing fluent from source code_ Precise local refresh of Redux