Jetty Server Architecture Analysis (II)

Source: Internet
Author: User

After talking about server startup, let's take a look at the request processing process,After the server is started, the server is on standby and the request comes. The request processing process is divided into two phases:

  • Request connection establishment process(ToNIOExample)

As mentioned above, a thread is allocated from the thread pool to wait for a new connection, that is, the listening thread. When there is no request, the thread is blocked inAccept()Method. When a new connection is established,AcceptMethod assignedSocketAnd set itNonblocking,The last thing to do isSocketToAcceptorThread(Basically equal opportunity)Processing, and then immediately return to continue in the accept state, can this thread work is quite simple, the efficiency is also quite high.

AcceptorThere are many threads(All come from the thread pool and are allocated in a fixed manner based onJetty. xmlIn configurationAcceptorsConfiguration quantity)Every thread maintainsSelectSet,EachSelectSetCorresponds to anotherSelector,These threads check whether there are tasks, suchChangesWhether there are tasks in the queue and there is a new connection, then quickly establishEndpoint

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.