You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by GitBox <gi...@apache.org> on 2022/06/10 03:10:33 UTC

[GitHub] [servicecomb-java-chassis] hailin84 opened a new issue, #3051: 是否有计划支持类似于async servlet这种机制

hailin84 opened a new issue, #3051:
URL: https://github.com/apache/servicecomb-java-chassis/issues/3051

   场景:
   扫码登录:
   页面展示二维码,一个long polling请求检查服务端扫码结果,这个请求在服务端不会立即返回,而是标注成async,然后进入异步线程池执行任务,Http处理线程见到这个请求是异步的,就知道先不将响应写回客户端,也不做flushbuffer、释放资源之类的操作(即客户端暂时不会收到响应),然后就完成了处理,释放Http处理线程。服务端异步任务执行完毕(超时或者成功处理),重新进入Http请求处理流程,这时候通过异步相关的标志得知,这个请求不再需要走前面的处理逻辑,而是只需要把响应写回即可。
   
   如果服务端返回超时,那么客户端立即开始下一次long polling请求。long polling的好处就是一旦扫完码,页面客户端马上就能感知到结果。比普通的页面客户端轮询效果更好。
   
   跟reactive还是有区别的。async servlet不占用Http处理线程,但是会占用TCP连接,因为必须没响应客户端,所以连接不会关闭。相对来说,能支持的TCP连接数是远大于线程数的,所以async servlet可以做到比较高的吞吐量。


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@servicecomb.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [servicecomb-java-chassis] hailin84 commented on issue #3051: 是否有计划支持类似于async servlet这种机制

Posted by GitBox <gi...@apache.org>.
hailin84 commented on issue #3051:
URL: https://github.com/apache/servicecomb-java-chassis/issues/3051#issuecomment-1152061129

   我们没有用Servlet,用的是Rest Over Vert.x。想要达到类似的效果。


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [servicecomb-java-chassis] hailin84 commented on issue #3051: 是否有计划支持类似于async servlet这种机制

Posted by GitBox <gi...@apache.org>.
hailin84 commented on issue #3051:
URL: https://github.com/apache/servicecomb-java-chassis/issues/3051#issuecomment-1152090641

   所有的文档我都反反复复翻了几遍了。你对比一下Tomcat的实现,就知道over Vert.x是压根不支持了。代码里也没有预留扩展点。这有个Tomcat的源码分析:
   https://www.helloworld.net/p/6353081200
   
   over servlet应该是天然就支持的,毕竟Tomcat有实现。你们不打算支持就算了吧,我们只能想想其他办法了。


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [servicecomb-java-chassis] liubao68 commented on issue #3051: 是否有计划支持类似于async servlet这种机制

Posted by GitBox <gi...@apache.org>.
liubao68 commented on issue #3051:
URL: https://github.com/apache/servicecomb-java-chassis/issues/3051#issuecomment-1152051526

   我觉得我的理解是对的,但不是很清楚你的疑问点在哪里。 建议可以试试 servlet 模式跑一下 java chassis, 可以帮助理解。 
   参考 [embededed servlet](https://servicecomb.apache.org/references/java-chassis/zh_CN/using-java-chassis-in-spring-boot/introduction.html) 或者 [standalone tomcat](https://servicecomb.apache.org/references/java-chassis/zh_CN/transports/rest-over-servlet.html) .   [samples](https://github.com/apache/servicecomb-samples) 有对应的例子。 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [servicecomb-java-chassis] hailin84 commented on issue #3051: 是否有计划支持类似于async servlet这种机制

Posted by GitBox <gi...@apache.org>.
hailin84 commented on issue #3051:
URL: https://github.com/apache/servicecomb-java-chassis/issues/3051#issuecomment-1151910031

   @liubao68 你说的跟我说的不是一回事。你指的异步是说servlet不在event-loop里执行而是在另一个单独的线程池执行吧?但是不管在哪里执行,执行完就立马响应客户端了。我说的这个场景线程可以执行完毕,但是不响应客户端。而是等到后面异步工作做完,再响应客户端。换句话说是需要将处理请求的流程分成两段,第一段是执行Controller、Filter等业务逻辑,第二段是根据把Response写回给客户端。第二段需要检查一下是否是异步,如果是,则先不写回。整个处理流程需要提供重入机制。我看代码主要是在AbstractRestInvocation里,并没有看到相应的机制。


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [servicecomb-java-chassis] liubao68 commented on issue #3051: 是否有计划支持类似于async servlet这种机制

Posted by GitBox <gi...@apache.org>.
liubao68 commented on issue #3051:
URL: https://github.com/apache/servicecomb-java-chassis/issues/3051#issuecomment-1152095916

   可以再看看 [异步处理的使用](https://servicecomb.apache.org/references/java-chassis/zh_CN/build-provider/reactive.html) 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [servicecomb-java-chassis] liubao68 commented on issue #3051: 是否有计划支持类似于async servlet这种机制

Posted by GitBox <gi...@apache.org>.
liubao68 commented on issue #3051:
URL: https://github.com/apache/servicecomb-java-chassis/issues/3051#issuecomment-1151895858

   java chassis的所有请求处理都是这种模式的。工作于servlet模式下,使用的是async servlet。 工作于vert.x模式下,也类似这种模式。


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [servicecomb-java-chassis] hailin84 closed issue #3051: 是否有计划支持类似于async servlet这种机制

Posted by GitBox <gi...@apache.org>.
hailin84 closed issue #3051: 是否有计划支持类似于async servlet这种机制
URL: https://github.com/apache/servicecomb-java-chassis/issues/3051


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [servicecomb-java-chassis] liubao68 commented on issue #3051: 是否有计划支持类似于async servlet这种机制

Posted by GitBox <gi...@apache.org>.
liubao68 commented on issue #3051:
URL: https://github.com/apache/servicecomb-java-chassis/issues/3051#issuecomment-1152070188

   Rest Over Vert.x类似的, 感觉你只是对event-loop线程池和业务线程池的理解有误解。 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org