如何使用Servlet 3 @WebServlet&与Spring MVC 3异步? [英] How to use Servlet 3 @WebServlet & async with Spring MVC 3?
问题描述
我想将servlet 3.0异步支持与spring MVC集成。类似于:
I would like to integrate the servlet 3.0 async support with spring MVC. Something like:
@RequestMapping("/chat")
@WebServlet(name="myServlet", asyncSupported=true)
public String getMessage(String userName) {
......
}
是否可能?
推荐答案
不是那么快,实现良好的长期并不容易轮询。
你提到的方法效果很好,但是存在严重的线程饥饿问题
Not so fast, it is not that easy to implement good long polling. The method you mentioned works well, but there is a serious issue of "thread starvation"
如果你有1000个,那么每个Long轮询将耗尽一个线程并发用户你需要1000个线程来服务长轮询请求(大部分时间都在客户端浏览器上更新服务器端状态)
Each Long polling will use up one thread, if you have 1000 concurrent user you would need 1000 thread to service the long polling request ( which most of the time does update of the server side status on the client browser)
Jetty 6有一个继续模式whcih巧妙地释放长轮询请求的线程,以供真实的应用程序逻辑使用。
Jetty 6 has a continue pattern whcih cleverly releases the thread of long polling request to be used by rhe real application logic.
这篇关于如何使用Servlet 3 @WebServlet&与Spring MVC 3异步?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!