AJP(Apache JServ Protocol)是定向包协议。因为性能原因,使用​​二进制​​格式来传输可读性文本。​WEB服务器​​通过 ​TCP连接 和 ​SERVLET​容器连接。


 


外文名 Apache JServ Protocol 简    称 ajp 实    质 定向包协议 作    用 使用二进制格式来传输可读性文本


AJP是定向包协议。因为性能原因,使用​​二进制​​格式来传输可读性文本。​WEB服务器​​通过​TCP​连接和​SERVLET​容器连接。为了减少进程生成socket的花费,WEB服务器和SERVLET容器之间尝试保持持久性的TCP连接,对多个请求/回复循环重用一个连接。一旦连接分配给一个特定的请求,在请求处理循环结束之前不会再分配。换句话说,在连接上,请求不是多元的。这个使连接两端的编码变得容易,虽然这导致在一时刻会有很多连接。


一旦WEB服务器打开了一个到SERVLET容器的连接,连接处于下面的状态:


◆ 空闲


这个连接上没有处理的请求。


◆ 已分派


连接正在处理特定的请求。


一旦一个连接被分配给一个特定的请求,在连接上发送的基本请求信息是高度压缩的。在这点,​​SERVLET​​容器大概准备开始处理请求,当它处理的时候,它能发回下面的信息给​​WEB服务器​​:


◆ SEND_HEADERS


发送一组头到浏览器。


◆ SEND_BODY_CHUNK


发送一块主体数据到浏览器。


◆ GET_BODY_CHUNK


从请求获得下一个数据如果还没有全部传输完,如果请求内容的包长度非常大或者长度不确定,这是非常必要的。例如上载文件。注意这和HTTP的​​块传输​​没有关联。


◆ END_RESPONSE


结束请求处理循环。


 


 


 



The Apache JServ Protocol (AJP) is a ​​binary protocol​​ that can ​​proxy​​ inbound requests from a ​​web server​​ through to an ​​application server​​ that sits behind the web server.

It also supports some monitoring in that the web server can ​​ping​​ the application server. Web implementors typically use AJP in a ​​load-balanced​​ deployment where one or more front-end web servers feed requests into one or more application servers. Sessions are redirected to the correct application server using a routing mechanism wherein each application server instance gets a name (called a route). In this scenario the web server functions as a​​reverse proxy​​ for the application server. Lastly, AJP supports request attributes which, when populated with environment-specific settings in the reverse proxy, provides for secure communication between the reverse proxy and application server.​[1]​​[2]

AJP runs in ​​Apache HTTP Server​​ 1.x using the ​​mod_jk​​ ​​plugin​​ and in Apache 2.x using the provided Proxy AJP, ​​mod_proxy​​ and proxy balancer modules together. Implementations exist for the not-yet-released ​​lighttpd​​ version 1.5,​[3]​​​nginx​​,​[4]​ ​​Grizzly​​ 2.1,​[5]​ and the ​​Internet Information Server​​.​[6]

The ​​Apache Tomcat​​ and ​​JBoss AS/WildFly​​ ​​servlet​​ containers support AJP.