Web Servers

Web Servers

Understanding web servers from scratch

Intro

Before we dive into the world of web servers, let's take a step back and ask ourselves a question: why should we even be learning about it?

Well, most of the applications that we use today are being moved to and are currently hosted by the cloud. What is a cloud? It is a global network of remote servers that are connected to form a single hosting computing system.

Users can access the computing resources such as storage, processing power, and software and manage data through the cloud. It allows for scalable and flexible solutions as users can pay and utilize the resources as per their use.

Standalone vs client-server applications

Any kind of application, whether it is a desktop app, a web app, or a mobile app, can be developed using some popular programming languages like javascript, java, python, Go, Rust, etc. Depending on the type of application, they can be categorized into standalone and client-server applications.

For instance, a desktop calculator app is a standalone. It does some basic mathematical calculations. All the logic is built inside of it. It neither makes any external communication nor depends on any server.

By definition, a standalone application is a software program that can operate independently without requiring additional software dependencies. It doesn't rely on a web browser, a server, or other applications to function. It can be installed and run on a device without the need for constant internet connectivity.

On the other hand, let's take another desktop application called Slack. It is a messaging platform where you can professionally have group discussions in a team and direct messaging for one-to-one communication too.

When messages are sent to other users, this app needs to communicate with a server to deliver them to a respective client. Slack also needs to make sure that there is a backup for all the messages being sent in case the users want to check the chat history.

There is a need for a server because it is responsible for receiving messages from different users. A single server can have multiple clients from different sources. It can have web clients, desktop app clients, or mobile app clients. There could be thousands of such users accessing the same application through different client sources at the same time.

For all these purposes, the Slack app needs to connect to a server. In that case, we have a server and the app itself acts as a client. Hence it follows a client-server model.

So what is a server and what kinds?

A server is a computer system that is dedicated to providing services to clients such as hosting websites, managing email communication, storing and retrieving files, or running applications. They often have more processing power, memory, and storage capacity than typical personal computers to handle the demands of billions and millions of users simultaneously.

All the websites that we see today that load web pages are run by web servers that host content like HTML, CSS, Javascript, etc. So, a web server is a program that uses HTTP to deliver files that, when requested by users and sent by their computer's HTTP clients, construct web pages for them.

Behind the web servers are usually the application servers that run application logic. For example, retrieving and updating databases, executing business logic like performing some kind of computing operation, and so on.

We have database servers too such as MySQL, PostgreSQL, MongoDB, etc. We also have email servers to process, retrieve and send emails to verified users, and backup servers to perform regular backups.

What makes a server, a server?

How are these servers able to receive chats, emails, web requests from clients and respond back to those requests? They can only receive something if they listen for it.

All of these servers have programs that listen for incoming requests on a particular port. It is these programs that makes them servers! Otherwise you are just a physical or a virtual machine with an operating system on it.

Any system could be a server such as your laptop if you run these programs on them. A lot of IoT devices have small lightweight servers that run on them such as raspberry Pis.

Web server vs application server

Web servers are responsible for serving web content such as HTML, CSS, javascript, etc. On the other hand, application servers are the backend servers that are responsible for running business logic.

For instance, in an e-commerce application, a web server connected to it, does the work of rendering the nice UI, product images you see on the website such as flipkart or amazon. But when the orders are processed, it is the application server that does the work of processing payments, updating the database on a database server, configure the order details, shipping details and other related stuff.

In a small scale applications, we may not see this distinction of work. It may just be a single application that hosts the web and application logic both in one place. This kind of architecture is not feasible and reliable once it scales up.

However, in large scale applications, the amount of work is split into many servers. There could be multiple application servers that handle different parts of the business logic. There could be multiple web servers to handle additional users along with multiple database servers to store and retrieve a huge amount of user data and product details.

Examples of web servers -

Some of the web servers are...

  1. Apache HTTPD

  2. Apache Tomcat

  3. NGINX

  4. Microsoft IIS (Internet Information Services)

  5. node.js

  6. Gunicorn

  7. Glassfish

  8. uWSGI

  9. LiteSpeed

.....and many more.