ICode9

精准搜索请尝试: 精确搜索
首页 > 编程语言> 文章详细

java – Spring netFlux在使用Netty与Tomcat时的不同之处

2019-09-26 15:01:11  阅读:541  来源: 互联网

标签:spring-webflux java tomcat nonblocking netty


我正在学习春天的webflux,我读过以下系列文章(first,second,third)

在第三条中,我面对以下案文:

Remember the same application code runs on Tomcat, Jetty or Netty.
Currently, the Tomcat and Jetty support is provided on top of Servlet
3.1 asynchronous processing, so it is limited to one request per thread. When the same code runs on the Netty server platform that
constraint is lifted, and the server can dispatch requests
sympathetically to the web client. As long as the client doesn’t
block, everyone is happy. Performance metrics for the netty server and
client probably show similar characteristics, but the Netty server is
not restricted to processing a single request per thread, so it
doesn’t use a large thread pool and we might expect to see some
differences in resource utilization. We will come back to that later
in another article in this series.

首先,我没有在系列中看到更新的文章,尽管它是在2016年编写的.很明显,tomcat默认有100个线程来处理请求,一个线程同时处理一个请求但是我没有理解短语它限于每个线程一个请求这是什么意思?

另外我想知道Netty如何为这个具体案例工作(我想了解与Tomcat的区别).它可以处理每个线程2个请求吗?

解决方法:

使用Servlet 2.5时,Servlet容器会向线程分配请求,直到该请求得到完全处理.

使用Servlet 3.0异步处理时,服务器可以在应用程序处理请求时在单独的线程池中调度请求处理.但是,当涉及到I / O时,工作总是发生在服务器线程上,并且总是阻塞.这意味着“慢客户端”可以独占服务器线程,因为在读取/写入具有较差网络连接的客户端时,服务器被阻止.

使用Servlet 3.1,允许异步I / O,在这种情况下,“一个请求/线程”模型不再存在.在任何时候,可以在由服务器管理的不同线程上调度位请求处理.

Servlet 3.1容器通过Servlet API提供所有这些可能性.应用程序可以利用异步处理或非阻塞I / O.在非阻塞I / O的情况下,范式的变化很重要,使用起来非常具有挑战性.

使用Spring WebFlux – Tomcat,Jetty和Netty没有完全相同的运行时模型,但它们都支持反应式背压和非阻塞I / O.

标签:spring-webflux,java,tomcat,nonblocking,netty
来源: https://codeday.me/bug/20190926/1820492.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有