Web Servers
Published: 2022-10-18 10:53:56

---
title: Web Servers
published: TRUE
date: 2022-09-09 06:45:38 UTC
tags: 
canonical_url: https://mennymo.hashnode.dev/web-servers
---

A web server simply put is really just a piece of software that serves web content.

> The main job of a web server is to display website content by storing, processing and delivering webpages to users.

A web server does the following in this specific order:

1. Listens
2. On a port
3. For a request
4. Through a Transport Protocol
5. Returns a Response
6. Containing the requesting Resource

### What does it mean for a web server to Listen?

To _listen_ means to prepare the the web server to accept client connection requests. When an application runs on a device, it has a unique port number attached to the process running.

For example, an HTTP server would listen on port 80 while an HTTPS listens on port 443. This means the server has created listening sockets on port 80 and 443 respectively.

While a web server is waiting for new connections, the kernel puts the process into an interruptible sleep state and runs other processes. This process of entering into 'deep sleep' is important because having the process poll continuously would waste CPU resources.

### How does the OS manage the web server?

The kernel is able to use the system resources more efficiently by blocking the process until there is work for it to do.

- As soon as the network receives new data, the network card issues an interrupt(break sleep).

- Seeing that there is an interrupt from the network card, the kernel, via the network card driver, reads the new data from the network card and stores it in memory. (This must be done quickly and is generally handled inside the interrupt handler.)

- The kernel processes the newly arrived data and associates it with a socket. A process that is blocking on that socket will be marked runnable, meaning that it is now eligible to run. It does not necessarily run immediately (the kernel may decide to run other processes still).
- At its leisure, the kernel will wake up the blocked web server process. (Since it is now runnable.) The web server process continues executing as if no time has passed. Its blocking system call returns and it processes any new data. 

![webserver.jpeg](https://cdn.hashnode.com/res/hashnode/image/upload/v1662705269038/0yUn_Hy3_.jpeg)_https://www.fastwebhost.in/blog/what-is-web-server-and-different-types-of-web-servers/_

### Definition

Now, how do we define web servers? A web server is software and hardware that uses HTTP (Hypertext Transfer Protocol) and other protocols to respond to client requests made over the World Wide Web.

### Protocols web servers support

The familiar **Hypertext Transfer Protocol (HTTP)** is most often associated with the World Wide Web. This is one of the transfer protocols in use on the internet. Others include: **File Transfer Protocol (FTP)** and**Simple Mail Transfer Protocol (SMTP)**. HTTP is the most used transport protocol for web services, and it plays a crucial role in REST.

### Uses of web servers

Web servers often come as part of a larger package of internet- and intranet-related programs that are used for:

- sending and receiving emails;
- downloading requests for File Transfer Protocol (FTP) files; and
- building and publishing webpages.

### Common and top web server software on the market

There are a number of common web servers available, some including:

- **Apache** HTTP Server. Developed by Apache Software Foundation, it is a free and open source web server for Windows, Mac OS X, Unix, Linux, Solaris and other operating systems; it needs the Apache license.
- **Microsoft Internet Information Services** (IIS). Developed by Microsoft for Microsoft platforms; it is not open sourced, but widely used.
- **Nginx**. A popular open source web server for administrators because of its light resource utilization and scalability. It can handle many concurrent sessions due to its event-driven architecture. Nginx also can be used as a proxy server and load balancer.

### How to secure a web server

There are a couple of security practices that can make for a safer experience

- Using **reverse proxy** : this is designed to hide an internal server and act as an intermediary for traffic on an internal server;
- Restricting access by connecting through the use of **_Secure Socket Shell (SSH)_** 
- Using a **firewall** and **SSL** : firewalls can monitor HTTP traffic while having a Secure Sockets Layer (SSL) can help keep data secure.

> Thank you for coming by. Do well to reach out on [LinkedIn](https://www.linkedin.com/in/omolade-akinwumi-554247144/) or [Twitter](https://twitter.com/Molly_ladson) for collaborations 😃

**References**

cover: _https://www.kissclipart.com/shared-hosting-clipart-shared-web-hosting-service-pfb9lz/_

_https://www.howtogeek.com/201958/how-do-web-servers-listen-for-new-requests/_

_https://www.microfocus.com/documentation/extend-acucobol/925/GUID-504F2B0D-9EAD-40BB-8E54-82B4C63E83F0.html_

_https://www.techtarget.com/whatis/definition/Web-server_