Search code examples
web-applicationsnetwork-programmingwebserver

How do webservers deliver requests by clients to application servers?


I know webservers, such as tomcat, deliver requests sent by clients to application servers to delegate the handling of the requests, as some related policies configured in the webservers. What I wonder is the way of delivering requests between them. Is the request data (headers, entity content) streamed from a the webserver to the backed application server while the data is being transferred by clients? Otherwise, is the data delivered to the backed application server after the entire data is completely arrived in the webserver?

Is this server-specific? I wonder the general action of this.


Solution

  • It depends on the protocol used between the web server and the application server, but most of the time, the data is sent/received on the fly.

    For instance, when using Apache as an http server, with Tomcat as an application server, people often choose the AJP protocol, that is packet-oriented. This protocol uses a binary format instead of a plain text one, for performances. The communication is based on TCP connections, and Apache tries to maintain those connections with the Tomcat container even if the connection between the web browser and Apache is closed and restarted on a new socket. Again, this is to improve performances.