In the world of client-server architecture, there is always a confusion related to what responsibilities are handled by a web server and an app server. In this post we will go deep into the roles played by both
What is Web Server
A Simple Web Server works on HTTP protocol and does the job of receiving the client requests and sending the responses back to the client. Most of the times the responses will include static HTML pages or images or simple redirection of the client request to the suitable program to handle them.
On a high level, it can be understood that web server do not handle the logic of business but simply delegates the task to some other program which generates the response. Web server simply takes that response and send it back to the client. Web servers are designed to handle Fault tolerance, Load balancing, Multiple Threads, etc.
Examples of Web Server: Tomcat
What is Application Server
Application Server is the super set of web server. The main responsibility of Application Server is to handle the business logic for client result processing. Segregating business logic from the Web Server provides flexibility to share the business logic by different clients.
Capabilities of Application Server includes Transaction Processing, Resource Pooling, Messaging, Security.
Examples of Web Server: Weblogic, JBoss, WebSphere
Why it is important to keep Web and App Server separate
Imagine a case when all the stuff of doing the business is handled by the web server. So in this case, server contains the script that performs the business logic and generates the result. Server then takes the result and sends the response back to the client
The main Disadvantage of this approach is in case of any issue or delay with HTTP Request/Response generation, the over all performance of the system goes down, even if there are no issues from the business processing side.
Another major disadvantage is that the business logic cannot be shared with different clients. So the logic cannot be reused at all which increases the cost of maintenance further.
In the above design, business logic is kept separate in application server. Thus, in case of fail the instance of web server changes and the application can keep on running without any issues with the same level of performance.
Considering the best practices, it is good to keep the business logic separate from re-usability point of view.