What is a Web Server, and How Does a Web Server Work?

Web servers are used for hosting websites and data for web applications. In this article, we explain a web server and how it works.

In 1989, the first web server, known as CERN httpd, was created to exchange information and a browser called WorldWideWeb. By the end of 1990, the first web page was served on the open internet, and in 1991, people outside of CERN were invited to join this new web community.

As people began to realize the effectiveness of transferring data across what is now known as the internet, multiple operating systems began to develop so that all could exchange data using computers.

If you run a website, it is essential to understand what a web server is, its function, and its role in delivering your website content to site visitors.

What is a Web Server?

Many people are familiar with how to view and navigate web pages but have limited knowledge of how those web pages do what they do. So here we will answer the question: “What is a web server?”

On the software side, a web server is computer software that uses the Hypertext Transfer Protocol, commonly known as HTTP, to store, process, and deliver web pages to the users.

These web pages are primarily static content such as HTML documents, images, videos, style sheets, etc.

On the hardware side, a web server is a computer that stores web server software and a website’s files. A website is a collection of web pages.

For a website to be available to everyone, it needs to be stored or “hosted” on a computer connected to the internet. Such a computer is known as a web server.

So the term “webserver” refers to both hardware and software but often refers only to the HTTP server software in the machine, which provides the website functionality.

To put things simply, the main job of a web server is to display the website content through storing, processing, and delivering web pages to users.

Servers typically run on two operating systems, Linux or Microsoft Windows. The most popular operating system to run web servers on is Linux, which most hosting companies do.

Many web server programs are available, but Nginx and Apache are undoubtedly the two most used web servers that power the internet today. Together, they are responsible for serving over 60% of traffic on the internet.

Related: Apache vs. Nginx: Which Web Server You Should Choose

How Does a Web Server Work?

Why is it important to understand the answer to the question? Because a website’s success is determined not only by its content and functionality but also by the efficiency of the web server that powers it.

When someone sits down at a computer and enters an address (URL) like www.google.com into a web browser, say Microsoft Edge or Google Chrome, the browser sends a request off into the internet asking to view the web page found at that address.

When a browser asks for a page through the web server, the process goes through many steps.

First, a DNS (Domain Name Server) converts this address to an IP address. Then, once the browser identifies the IP address of the server hosting the requested URL, it sends an HTTP request to it.

Finally, the webserver loads the website files from the disk and sends them out across the network to the user’s browser.

All websites on the internet have a unique identifier in terms of an IP address. In addition, every web page on the internet also has an individual address, called a Uniform Resource Locator, or URL.

A web server communicates with a web browser using the Hypertext Transfer Protocol (HTTP). Hypertext Transfer Protocol is the set of rules for transferring files over the web. The web server understands the URLs and the HTTP.

This entire exchange is mediated by the browser and server talking to each other using HTTP. Generally, the whole process happens so quickly it’s hardly even noticeable as users navigate from page to page.

This workflow is shown in the figure below.

How does web server work

In short, client devices send requests to servers for the resources needed to load a web page. The web server is the program or computer that responds to those requests and delivers the website’s content to the user.

A web server can host a single website or multiple websites using the same software and hardware resources, known as “virtual hosting.”

Static and Dynamic Content

Roughly speaking, a server can serve either static or dynamic content.

In the early days of the web, almost all websites were known as “static sites.” Content (text, images, audio, video, etc.) was placed or embedded in a simple HTML file.

When the webserver receives a request for a static page, the server reads the request, finds the file on the disk, and sends it to the requesting browser, as shown in the figure below.

Web Server Static Content

However, when the web server receives a request for a dynamic page, it reacts differently. First, it passes the page to a particular piece of software responsible for finishing the page. This specific software is called an application server.

Then, the application server scans the page for instructions and finishes the page, then passes the finished page back to the webserver.

Related: How To Configure Nginx To Work With PHP Via PHP-FPM

Dynamic pages refer to web content that changes based on user’s behavior, preferences, and interests. The content served out is generated dynamically, on-demand. Dynamic pages are written in programming languages such as Java, PHP, Python, etc.

Let me give you an example. If you have a Java-based web application, you will need specialized software that can work with Java code; the most widely used one is Apache Tomcat, a Java application server.

When a user sends a request, it is met by the frontend web server, for example, Nginx. However, because it does not understand Java, the frontend web server forwards the requested page to the Tomcat application server, which performs the necessary manipulations based on the Java code in the requested page and returns the finished response formatted as a pure HTML page to the frontend webserver. As a result, it returns the already finished page to the client.

This workflow is shown in the figure below.

Web Server Dynamic Content

In other words, the application servers extend the ability of a webserver to handle web application requests and much more.

Conclusion

Now you know what a web server is and how it works. At its core, request-response is the key to a server’s work, day in and day out.

Every time you open a new website page or do some online shopping, an array of near-instant processes are taking place in a server somewhere.

Please feel free to drop your comments if you want to share more information about the topic discussed above.

Bobby Borisov

Bobby Borisov

Bobby, an editor-in-chief at Linuxiac, is a Linux professional with over 20 years of experience. With a strong focus on Linux and open-source software, he has worked as a Senior Linux System Administrator, Software Developer, and DevOps Engineer for small and large multinational companies.

Think You're an Ubuntu Expert? Let's Find Out!

Put your knowledge to the test in our lightning-fast Ubuntu quiz!
Ten questions to challenge yourself to see if you're a Linux legend or just a penguin in the making.

1 / 10

Ubuntu is an ancient African word that means:

2 / 10

Who is the Ubuntu's founder?

3 / 10

What year was the first official Ubuntu release?

4 / 10

What does the Ubuntu logo symbolize?

5 / 10

What package format does Ubuntu use for installing software?

6 / 10

When are Ubuntu's LTS versions released?

7 / 10

What is Unity?

8 / 10

What are Ubuntu versions named after?

9 / 10

What's Ubuntu Core?

10 / 10

Which Ubuntu version is Snap introduced?

The average score is 68%

Leave a Reply

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