terminology – What is the difference between web server and application server?


What is the difference between web server and application server ? Where is/should each be used? Is there any interaction between them (a software can use both technologies together)?


An application server is simply a server, in the sense of the client-server architecture: a process that serves one or more client applications that send requests to it. Run a process that opens a port to listen for TCP or UDP connections, and voilà! , you have an application server.

In our web world we need different types of servers. One that understands requests made over the HTTP protocol, for example, to communicate with clients across the Internet. Minimally this server may be able to serve static data such as static HTML pages, files and images. It's called "Web Server". Example: the "Apache HTTP Server" or simply Apache.

But that alone is not enough. It is common to need it to serve dynamic data, such as custom HTML pages, byte strings, files and even images built based on variable information such as the parameters of the request itself or the result of a query to a database (this one by itself an application server too, as @Maniero said, only specialized in storing structured data).

One way to solve this is to implement a web server that has dynamic behavior. It's not very practical: depending on the size of the services it proposes to provide, we will have to dedicate ourselves to implementing a lot of logic, let's say, of "infrastructure" to build it, such as separating requests into threads to save resources and improve performance , security logic (authentication, authorization) preferably declarative (that is, based, for example, on a text file that someone can modify without having to recompile the entire server code), request filtering behavior (for example, the behavior of always authenticate requests intended to serve logged-in users before executing your logic), logging , the very logic of interpreting a dynamic page and generating the HTML (I'm blatantly getting all this from the book Head First Servlets & JSP which explains why it's better to do it differently, using a Container).

Another way to do it is to delegate the dynamic part to scripts written in Perl, PHP or some other language. It can also run into some of the aforementioned limitations, including opening a separate process for each request, which is more costly than using threads .

Another way is using a Container (also called Web Container or Servlet Container ), which is the solution proposed by Java technologies and which I know best. It is also a server, which receives requests from an HTTP server (aka Web server, remember?) and takes care of all the infrastructure logic mentioned above, leaving you free to implement only the business logic that interests your specific application. The Container forwards requests to Servlets, which are basically Java classes, and each Servlet executes the request in a thread . You can program one Servlet to fulfill login requests, another to add items to an order, another to exclude orders, and so on.

This is also often called an "Application Server" in the sense I believe you had in mind when you asked your question. It consists of a web server, and also an extra server, the Container, which is responsible for generating dynamic content. So we can say that in this second definition of application server, said application server contains a web server.

(Note that in this combined architecture it doesn't need to be a web server, nor does the protocol need to be HTTP; but it is the most common in the web world).

Example application server: Apache Tomcat (Apache web server + servlet container ). Note: Tomcat also has an alternate HTTP server called "Apache Tomcat HTTP Server".

In Java, an application designed to run in a container (usually called a "web application") is a .WAR file (short for "Web ARchive") which is basically composed of Servlets that the container will run with some more static content ( images, configuration files, etc).

Scroll to Top