AJP13

The ajp13 protocol is packet-oriented. A binary format was presumably chosen over the more readable plain text for reasons of performance. The web server communicates with the servlet container over TCP connections. To cut down on the expensive process of socket creation, the web server will attempt to maintain persistent TCP connections to the servlet container, and to reuse a connection for multiple request/response cycles.

Once a connection is assigned to a particular request, it will not be used for any others until the request-handling cycle has terminated. In other words, requests are not multiplexed over connections. This makes for much simpler code at either end of the connection, although it does cause more connections to be open at once.

Once the web server has opened a connection to the servlet container, the connection can be in one of the following states:

Idle
No request is being handled over this connection.
Assigned
The connecton is handling a specific request.
Once a connection is assigned to handle a particular request, the basic request informaton (e.g. HTTP headers, etc) is sent over the connection in a highly condensed form (e.g. common strings are encoded as integers). Details of that format are below in Request Packet Structure. If there is a body to the request (content-length > 0), that is sent in a separate packet immediately after.

At this point, the servlet container is presumably ready to start processing the request. As it does so, it can send the following messages back to the web server:

SEND_HEADERS
Send a set of headers back to the browser.
SEND_BODY_CHUNK
Send a chunk of body data back to the browser.
GET_BODY_CHUNK
Get further data from the request if it hasn't all been transferred yet. This is necessary because the packets have a fixed maximum size and arbitrary amounts of data can be included the body of a request (for uploaded files, for example). (Note: this is unrelated to HTTP chunked tranfer).
END_RESPONSE
Finish the request-handling cycle.
Each message is accompanied by a differently formatted packet of data.

get more details:
http://dl.iteye.com/topics/download/002e31d0-33a4-3727-8f58-51fbc0f5f740

你可能感兴趣的:(Web,socket,servlet,performance)