Skip to main content
BlogCloud OverviewsWeb Server Foundations

Web Server Foundations

Web_Server_Foundations_Overview

This post is part of our Cloud Computing Foundations series. Build your skills further by taking our Introduction to Cloud Computing certification course.

You may already be familiar with this concept. Remember the client/server model? Web servers are just a component of this model—the server. 

At a basic level, a web server stores and delivers websites and web applications. Web servers are composed of hardware and software that work together to facilitate the exchange of data. 

The hardware component of a web server refers to the physical or virtual computer that stores the website’s files and components. This includes everything from static HTML documents, text files, images, and videos to more complex dynamic scripts. For example, if you visit a website with a video on its homepage, that video is stored on the web server hardware.

The software component of a web server is responsible for controlling how users can access the files stored on the server. It does this by managing the requests that come in from web browsers and other devices connected to the internet. The software installed on the web server allows you to view websites in your web browser.

Let’s start by digging into the components that make web servers tick.

Hyper Text Transfer Protocol (HTTP)

HTTP enables web servers to deliver websites and web applications to users, so they can access and view content on the internet.

When you use a web browser to access a website, your web browser sends a request to the web server hosting that website. This request is in the form of an HTTP message. The web server receives and processes the request, retrieving the requested resource from its hardware and software components.

On the right in the image above, we can see that the web server sends a message to a web browser using HTTP. To request a website, we can simply type its URL into the browser’s address bar. The browser then maps this URL to an IP address, which represents the server’s physical location where the website is stored. If the server is found at this IP address, the web server software will receive the request and send back the website we asked for. So, if we typed “www.example.com” into the browser, the web server would return the website for “www.example.com.”

Self-Hosting vs. Hosting Provider

When it comes to hosting your web application, you have a choice between using a hosting provider or setting up your own server on your home computer. Individuals often self-host, but for organizations that provide essential services, a hosting provider offers much more protection.

With a hosting provider, you can take advantage of high-speed servers and networks. A hosting provider also has the ability to reliably handle fluctuating power consumption and protect from potential failure. But the biggest reason that we use hosting providers for essential services is to ensure private information doesn’t leak into the public domain. 

Web Server Software

Web server software is the heart of any website or web application. It enables us to serve web content to users over the internet. When we are setting up a website and configuring our servers, we need software to make it work.

In terms of software, two solutions dominate the market: Apache and NGINX. We’ll go over those two here, but it’s worth noting that there are other options including IIS, and Lighttpd, each with unique benefits and challenges.

Apache

Apache is a widely used web server software ideal for hosting dynamic content, such as eCommerce sites or forums. It can run on multiple platforms, including Windows, macOS, and Linux. It’s been around since about 1995 and is one of the oldest and most widely-used web servers available. 

Apache is capable of handling a variety of web protocols, including HTTP, HTTPS, and FTP, and can run on many different operating systems, including Windows, Linux, and macOS. It is highly customizable, with various modules that can add additional functionality like support for dynamic content, authentication, and caching. It was specifically built to process dynamic content within the server itself, independent of any server components. 

Apache has a one-connection-per-process model. A one-connection-per-process model is a traditional approach to building web servers where each client connection is handled by a separate process or thread. This process, or thread, is responsible for managing the client’s connection and processing their requests until the connection is closed. Because Apache uses this model, server performance is significantly degraded when the number of concurrent connection requests surpasses the number of processes.

One of the key features of Apache is its ability to support multiple virtual hosts on a single server, allowing websites to share resources while maintaining their unique configurations. Apache is also highly extensible, with a large community of developers creating and maintaining additional modules and plugins to extend its functionality.

NGINX

On the other hand, NGINX (pronounced Engine X) is optimized for serving static content like images and videos and is popular for its ability to handle large numbers of simultaneous client connections. NGINX is highly valued for its ability to improve content delivery over the web. 

NGINX was built using an asynchronous, event-driven model. Let’s go over those concepts for a moment. 

We use asynchronous models when a system needs to handle many simultaneous requests, such as in web servers, network communication, and database management. By using an asynchronous programming model, these systems can achieve better performance and scalability and reduce the risk of blocking and freezing.

An event-driven model is driven by events in the system rather than following a predetermined sequence of steps.

So, having an asynchronous and event-driven model allows a system to handle multiple tasks and events together without blocking the processing of other tasks.

Because of its architecture, NGINX cannot process dynamic content, such as PHP. It must pass it on to an external processor for execution. For this reason, NGINX is more suited for static content, reverse proxy, load balancing, mail proxy, and HTTP caching. NGINX is also recommended for Linux systems.

Using NGINX and Apache Together

NGINX and Apache are often used together. By doing so, we can leverage each server’s strengths while overcoming their limitations.

One of the most common methods of integrating Apache and NGINX is by placing NGINX in front of Apache to handle all incoming HTTP requests, as seen in the above image.  This configuration involves directing all incoming HTTP requests to NGINX, which then relays requests for dynamic content to Apache while serving requests for static content by itself.

By placing NGINX in front of Apache, we take advantage of NGINX’s ability to handle large volumes of simultaneous connection requests with its asynchronous, event-driven model. This helps alleviate some of the strain on Apache by reducing the number of open threads and processes required to handle requests, which can otherwise degrade Apache’s performance.

The reverse proxy configuration also provides additional benefits, such as load balancing and improved security. NGINX can distribute requests across multiple Apache servers, balancing the load and preventing any single server from becoming overwhelmed. Additionally, NGINX can act as a buffer between the internet and the web server, providing an extra layer of protection against attacks.

Build the skills to succeed in cloud computing by taking our Introduction to Cloud Computing certification course.


Comments (1)

  1. Author Photo

    Crystal clear blog, loved the explanation!

Leave a Reply

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