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.
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.
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.
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.
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.
In other words, the application servers extend the ability of a webserver to handle web application requests and much more.
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.