码头如何处理多个请求 [英] How does jetty handle multiple requests

查看:153
本文介绍了码头如何处理多个请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用Jetty/tomcat应用服务器处理Spring Web应用程序大约两年了,但是,令我难过的是如何在这些服务器中处理多个请求.我知道春天有助于单身人士,但我的理解仅限于此. 有人可以指出任何可以帮助我了解如何处理多个请求的优质资源.

I have been working with spring web applications using jetty/tomcat app server for around two years now, however the thing that eludes me still is how are multiple requests handled in these servers. I understand that spring is helpful in making singletons, but my understanding is just limited to that. Can someone point to any good resource that can help me understand how multiple requests are handled.

推荐答案

这个问题可以在很多层面上得到解答,我一直盯着它看了两天,试图弄清楚答案是什么...所以我将有点高水平的射击.

This can be answered at so many levels I have been staring at it for two days trying to figure out how answer it...so I'll take a kinda high level shot at it.

Jetty侦听此服务器端口,还有一些接收器线程,其任务是获取在客户端和服务器端之间建立的连接对象.建立连接后,它将流经码头处理程序体系结构,执行诸如身份验证之类的工作,或者获取会话ID并将会话对象附加到请求.然后将其工作到servlet处理程序中,并找到适当的servlet,然后开始处理servlet-api.那时,至少在Servlet 2.5下,您一直在使用servlet-api时一直为您的请求分配一个线程.在Servlet 3.0中,您可以使用一些异步机制,也可以使用码头连续性作为对Servlet 2.5 api获得异步支持的一种方式.

There is this server port that jetty listens on and some number of acceptor threads whose job it is to get connection objects made between the client and server side. Once you have that connection it flows through the jetty handler architecture doing things like authentication perhaps, or pulling off a session id and attaching a session object to the request. Then it works its way into the servlet handler and the appropriate servlet is found and you start dealing with the servlet-api. At that point you have a thread allocated to your request for all of the time you are in the servlet-api, at least under servlet 2.5. In servlet 3.0 you have some async mechanisms available to you, or you can use jetty-continuations as a way to get async support on servlet 2.5 api.

无论如何,服务器使用一个线程池来将线程分配给那些连接器,这些连接器最终是将所有时间都花费在servlet-api中的线程.码头续航api和更新的servlet 3.0支持提供了将线程释放回主线程池的机制,以便他们可以花时间接受和处理其他请求.

Anyway, there is a thread pool that the server uses to allocate threads to those connectors which ultimately are the threads spending all their time in the servlet-api. The jetty continuations api and the newer servlet 3.0 support provide mechanisms to release threads back to the primary threadpool so they can spend time on accepting and processing other requests.

与nio api的使用以及码头如何有效地管理所有这些东西有关的内容显然还有很多事情要做,但这也许足以解决您的第一个问题.如果没有,请仔细阅读码头文档( http://www.eclipse.org/jetty/文档/当前版本),或者查看码头邮件列表.在Webtide的博客中,有关Jetty-9优化的讨论已经涉及到http,spdy和websocket连接的处理和处理( http://webtide.com/blogs ).

There is obviously a lot more going on under the covered related to usage of the nio api's and how jetty efficiently manages all of this stuff, but maybe this is enough to sate your initial question. If not, feel free to peruse the jetty docs (http://www.eclipse.org/jetty/documentation/current) or look to the jetty mailing lists. There has been some discussion on jetty-9 optimizations as it relates to under the covers with http, spdy, and websocket connection handling and processing in the blogs at Webtide (http://webtide.com/blogs).

这篇关于码头如何处理多个请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆