Web Development – Application Server & Web Server (Quick Notes)

Application Server vs Web Server

Application server is the superset of Web server.
The main difference between the Web server and an Application server is that a web server is meant to serve Static content e.g. HTML and CSS, while Application Server is responsible for generating Dynamic content by executing server-side/back-end code.

A Web server is designed to handle HTTP requests and responses and is responsible for serving static content (such as HTML pages) to client devices over the internet. A web server does not execute application code but rather serves as a channel for requests and responses between the client and the application.

An Application server, on the other hand, is a type of server that is designed to host and run applications. An application server provides an environment for executing applications and includes features such as a runtime environment, a database connection pool, and support for various protocols and APIs.

Dynamic content

Dynamic content refers to website content that changes based on user input or other factors. This can include things like personalised recommendations or customised displays based on the user’s location or browsing history. Dynamic content is often generated by making API (Application Programming Interface) calls to the back-end, rather than being a static part of the website’s HTML code. Dynamic content can make websites more interactive and engaging for users, as it provides a more personalised and customized experience.

Static content

Static content refers to website content that does not change. It is a part of the website’s HTML and CSS code, rather than being generated dynamically in response to user input or other factors. Static content can include things like static text, media, etc that are part of the website’s design and layout. It is called “static” because it does not change unless its content is updated by changing the HTML & CSS code of the website.

Why do we need a Web server along with an Application server?

It can be useful to have a web server because:

  1. Performance: A web server is designed to handle static content and can serve it much more quickly than an application server. By using a web server in front of the application server, static content can be served more efficiently, improving the overall performance of the website.
  2. Virtual Hosts: You can give the appearance of many different hosts all operating on the same IP address. You can create Virtual-Hosts on your main server that will accept requests from designated servers and route them to the correct ports. These Virtual-Hosts can be defined in the configuration file.
  3. Security: A web server can act as a first line of defense, protecting the application server from certain types of attacks. For example, a web server can be configured to block certain types of requests or to filter out malicious traffic before it reaches the application server.
  4. Scalability: A web server can be horizontally scaled, meaning that it can handle more traffic by adding more instances of the server. This can be useful in situations where the website experiences a sudden increase in traffic.
  5. Load balancer: Perhaps the single greatest use of a web server is the ability to load balance traffic in a cluster. Web server makes this easy to achieve. Load balancing allows web servers to act as your bouncer, dividing traffic evenly among all members of your cluster.
Example of application-server & web-server used together (Ruby on Rails)

Nginx and Phusion Passenger are often used together as a web server and application server combination to serve Ruby on Rails web applications.

Nginx is a lightweight, high-performance web server and reverse proxy server that is known for its ability to handle a large number of simultaneous connections efficiently. It is often used as a front-end server to handle incoming web requests and to distribute them to backend application servers.

Phusion Passenger is an application server that can host and manage Ruby on Rails applications. It is designed to work seamlessly with Nginx, providing an easy-to-use and efficient way to deploy Ruby on Rails applications.

How do they work together?

Nginx acts as a front-end server, handling incoming web requests and forwarding them to the Phusion Passenger application server. Phusion Passenger then processes the requests, running the Ruby on Rails application code and returning the response to Nginx, which in turn delivers it back to the client.
The combination of Nginx and Phusion Passenger provides a fast and reliable way to serve Ruby on Rails web applications, with Nginx handling the load balancing and proxying, and Phusion Passenger handling the application hosting and management.

Other examples of application-server & web-server used together

1- Go

  • Application Server: Go’s built-in HTTP server or Caddy
  • Web Server: Nginx or Apache HTTP Server

2- Java

  • Application Server: Tomcat, Jetty, or GlassFish
  • Web Server: Nginx or Apache HTTP Server

3- Node.js

  • Application Server: Express.js
  • Web Server: Nginx or Apache HTTP Server

4- PHP

  • Application Server: PHP-FPM
  • Web Server: Nginx or Apache HTTP Server

5- Python

  • Application Server: uWSGI, Gunicorn, or mod_wsgi
  • Web Server: Nginx or Apache HTTP Server

Leave a Reply

Your email address will not be published. Required fields are marked *