A lot of views all around the web could be found regarding the discussion on difference between a Web-server and an Application server.Even I am not sure of the exact difference between the two.I am compiling this post so that we can try to shed out some light on this so as to come with some understanding on this topic terms pf a laymen.I would request the readers of this post to share their views using simple language and without using vague terms. Lets start..
I read an example on some forum which I quite liked.It stated as below.
“Web-server actually process static content, like when we request to access a webpage like Google , it will go to the web server first and as is expected and the Google home page will be displayed .Now application server comes into picture. When we enter something in search box , like something we wanna search ,now here application server comes into action as the web server alone cannot take the dynamic request.The web server can employ various strategies for fault tolerance and scalablity such as load balancing, caching, and clustering but it cannot search the database and do lot of processing.Application server is actually a software.”
This means that the web server accepts requests from the user from a browser using HTTP protocol and then forward it to application server for further action.Lets note a point here that the capability of the application server is just not limited to accepting requests using HTTP protocol, it can also accept requests using other protocol such as RMI/RPC whereas the web-server just serves to the HTTP request.
Eg of webservers : Apache HTTP Server, Sun ONE Web Server, iPlanet Web Server
Web Servers are mostly designed to serve static content. Though most of the Web Servers are having plugins to support scripting languages like Perl, PHP, ASP, JSP etc. through which these servers can generate dynamic HTTP content.Most of the application servers have Web Server as integral part of them, that means Application Servers are capable of whatever Web Server is capable of. Additionally an Application Server have components and features to support Connection Pooling, Object Pooling, Transaction Support, Messaging services etc.
As web servers are well suited for static content and app servers for dynamic content, most of the production environments have web server acting as reverse proxy to app server.The web server resides between the web browser and application server and the request from the user’s browser is first intercepted by the web server and then forwarded to the app server. This means when a page request comes from the user , static contents such as images/static html is served by web server that interprets the request and then using some kind of filtering technique (mostly extension of requested resource) web server identifies dynamic content request and transparently forwards to app server.Then the application server exposes the application logic for use by client application programs. The application program can use this logic just as it would call a method on an object.In most cases, the app server exposes this business logic through a component API, such as the EJB (Enterprise JavaBean) component model found on J2EE (Java 2 Platform, Enterprise Edition) application servers.
Example of such configuration is
- Apache HTTP Server and BEA WebLogic Server. Apache HTTP Server is Web Server and BEA WebLogic is Application Server.
- Apache HTTP Server and Tomcat Server. Apache HTTP Server is Web Server and Tomcat is Application Server.
- Internet Information Server and SharePoint Server. IIS is a web server; SharePoint is an application server. SharePoint sits “on top” of IIS, executes specific logic, and serves the results via IIS.
So ,question arises that when an application server not only hosts an application but also can perform the functions of a webserver then whats the need of a webserver. The answer would be that an architect would never choose to expose the server on which his application is hosted, directly to the users request, keeping security in my mind.
Readers please pour in your suggestions and thoughts.
Also a relevant discussion could be found on http://www.javaworld.com/javaqa/2002-08/01-qa-0823-appvswebserver.html