Web servers are used for hosting websites and data for web applications. In this article, we explain what is a web server and how does it work.
In 1989, the first web server, known as CERN httpd, was created with the objective to exchange an information, along with 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 important to understand what web server is, how does it work, and what role it play 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. 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 mostly 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 web site is a collection of web pages. For a web site to be available to everyone, it need to be stored or “hosted” on a computer that is connected to the internet. Such a computer is known as a web server.
So the term “web server” 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 one of two operating systems, Linux or Microsoft Windows. The most popular operating systems to run web servers on is Linux, which is what most hosting companies do.
There are many web server programs 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 a Web Server Works
Why is it important to understand the answer to the question? Because the success of a website doesn’t just depend on its content and functionality but also the efficiency of the web server used to power it.
When someone sits down at a computer and enters an address (URL) like
www.google.com into a web browser, say Firefox 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. A DNS (Domain Name Server) converts this address to an IP address. Once the browser identifies the IP address of the server hosting the requested URL, it sends an HTTP request to it. In response, the web server loads the website files from disk and serves it out across the network to the user’s browser.
All websites on the internet have a unique identifier in terms of an IP address and every web page on the internet also has a unique 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 content of the website back to the user.
A web server can host a single website or multiple websites using the same software and hardware resources, which is 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 web sites were what is known as “static sites.” Content (text, images, audio, video, etc), was placed or embedded in a simple HTML file. When the web server 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 is shown in the below figure.
When the web server receives a request for a dynamic page, however, it reacts differently. It passes the page to a special piece of software responsible for finishing the page. This special software is called an application server. The application server scans page for instructions and finishes page, then passes finished page back to web server.
Dynamic pages refers to web content that changes based on the behavior, preferences, and interests of the user. The content served out is actually generated dynamically, on-demand. Dynamic pages are written in languages such as Java, PHP, Python, etc.
This workflow is shown in the figure below.
Application servers extend the ability of a web server to handle web application requests, and much more.
Now you know what is a web server and how does it work. At its core, request-response is the key to what work a server does, 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 you comments if you want to share more information about the topic discussed above.