Friday, August 29, 2008

What is Apache JServe Protocol (AJP)

While I was researching on SOA server administration I learned about a new protocol being used inside the server for its internal communication named Apache JServe Protocol . I would like to share some info on this protocol.

The Apache JServe Protocol (AJP) is a binary protocol that can conduit inbound requests from a web server through to an application server that sits behind the web server. It also supports some monitoring in terms of the web server being able to ping the application server. AJP is typically used in a load balanced deployment where one or more front-end web servers feed requests into one or more application servers.

The AJP 1.3 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 connection is handling a specific request.

Once a connection is assigned to handle a particular request, the basic request information (e.g. HTTP headers, etc) is sent over the connection in a highly condensed form (e.g. common strings are encoded as integers). If there is a body to the request (content-length > 0), that is sent in a separate packet immediately after.

Courtesy (Wikipedia & Apache-Dan Milstein)

No comments: