HTTP vs AJP Protocol – Which one should be used?
An http request comprises a series of lines of data, each new line terminated. The first of these lines comprises the request method (such as GET or POST) followed by the name of the resource required (such as /index.html) followed by a protocol version (such as HTTP/1.1). Subsequent lines include such things as the name of the host being contacted, referrer headers, cookies, the type of the browser, preferred language, and a whole host more details. In HTTP/1.1 only the name of the host being contacted is required in subsequent lines – the rest are conditional or optional. In the case of the POST method, the header is followed by the data that’s associated with the request. An http requested is followed by a blank line which indicated that it is complete.
The http protocol is quite expensive in terms of band width – it’s an ascii text protocl with words like “POST” and phrases like “Content-type:” taking up more bandwidth than is really needed, and having to be interpreted at destination too. So the ajp protocol (Apache Java Protocol?) was established to allow for much less expensive exchanges between upstream and downstream servers that are to be closely linked.
AJP carries the same information as http but in a binary format. The request method – GET or POST – is reduced to a single byte, and each of the additional headers are reduced to 2 bytes – typically, that’s about a fifth of the size of the http packet.