Basically this protocol is used for communication between Apache and Application server.
There's some non-trivial overhead to parsing http headers on requests and creating them on responses.
If you are fronting your app server with a web proxy server, AJP allows you to skip that extra parsing and just pass efficient binary
representations of the headers between the proxy server and the app server.
There are other benefits with things like simple connection pools and tight integration if you use apache/mod_jk.
Client (using HTTP/S) ----> Proxy server (using HTTP/S) ---> Application Server
vs
Client (using HTTP/S) ----> Proxy server (using AJP) ---> Application Server
AJP (Apache Jserv Protocol) is basically a binary protocol that allows to reverse proxying requests from a
frontend Web Server to a backend Application Server, effectively propagating all the needed information to make
the RRequest->Response flow continuing successfully.
[ A binary protocol is a protocol which is intended to be read by a machine rather than a human being, as opposed to a
plain text protocol such as IRC, SMTP, or HTTP/1.1.
Binary protocols have the advantage of terseness, which translates into speed of transmission and interpretation.]
AJP is used mainly because:
(1) it's more performant than any HTTP exchange,
(2) it's integrated with broadly used reverse-proxying modules (i.e. mod_jk, mod_proxy),
(3) Tomcat's implementation provides a rich set of APIs that is protocol transversal:
HTTP(s) data is seamlessly propagated, and can be retrieved with simple API calls (canonical getXYX(),
very effective and immediate),
so it's like working with HTTP at a higher speed.
Digging more into AJP
(a) The Apache JServ Protocol (AJP) is a method for a web server to communicate with an associated application server.
The web server is a
"reverse proxy," meaning, its purpose is to handle incoming traffic from the Internet on behalf of the application server.
(b) Web traffic is carried out in HTTP (Hypertext Transfer Protocol), which also carries through to communication
between servers working together to fulfill a request. HTTP is a plain-text format where actual words make up the messages
running between computers. This create an overhead of traffic.
AJP converts these messages into a binary code, reducing the amount of space taken by each message.
(c) Speed between collaborating servers is a distinctive feature of the protocol.
The process maintains permanent connections between servers to reduce the time taken to establish contact.
The link is dedicated to a particular request and then maintained for the next request to be tunneled down,
rather than each session causing a session to be created and broken.
(d) AJP is particularly used for "Load Balancing."
This is where one server distributes incoming traffic among several application servers, sharing the load equally.
Proxy Server (Forward Proxy) and Reverse Proxy explained
Beautiful explanation is
here
Summarizing the Key points, but its advised to read the above explanation to have a wonderful knowledge,
with diagrams.
What’s a proxy server?
A forward proxy, often called a proxy, proxy server, or web proxy, is a server that sits in front of a group of client machines.
When those computers make requests to sites and services on the Internet, the proxy server intercepts those requests and then
communicates with web servers on behalf of those clients, like a middleman.
Why would anyone add this extra middleman to their Internet activity? There are a few reasons one might want to use a forward proxy:
- To avoid state or institutional browsing restrictions
- To block access to certain content
- To protect their identity online
How is a reverse proxy different?
A reverse proxy is a server that sits in front of one or more web servers, intercepting requests from clients.
This is different from a forward proxy, where the proxy sits in front of the clients.
With a reverse proxy, when clients send requests to the origin server of a website,
those requests are intercepted at the
network edge by the reverse proxy server.
The reverse proxy server will then send requests to and receive responses from the origin server.
Read about "Edge computing" and "Network edge" from
here
Difference ?
A forward proxy sits in front of a client and ensures that no origin server ever communicates directly with that specific client.
On the other hand, a reverse proxy sits in front of an origin server and ensures that no client ever communicates directly with that origin server.
Some of the benefits of a reverse proxy:
- Load balancing
- Protection from attacks like DDoS
- Global Server Load Balancing (GSLB)
- Caching
- SSL encryption