Introduction to Web Servers
Web Servers play an important role in connecting people around the world through the internet. Every day, users send millions of requests for content via their web browsers, and it’s web servers that answer those calls.
In this introduction to web servers, we’ll look at how this request-and-response routine works, and get some more details about the capabilities and functionalities of web servers.
If you’d prefer the video version of this article, you can watch it here:
Requests and Responses
A user’s website experience is built on a series of requests and responses.
First the user opens their browser and enters a URL. Let’s say, example.com
.
Every device that is connected to the internet has a unique IP address. Think of it like a phone number. The browser sends a request to the Domain Name System (DNS) to look up the IP address that belongs to example.com
‘s web server. Using DNS to translate a URL into an IP address allows your browser to know exactly where to send the request.
The DNS Request
A DNS request is processed through a hierarchy of servers:
- The Recursive Resolver receives the initial request and passes it along to the closest Root Nameserver
- The Root Nameserver has information about top-level domains (TLDs), such as
.com
,.net
, and all of the country-based domains, so it instructs the Recursive Resolver to pass along the request to the appropriate TLD Nameserver. - The TLD Nameserver stores information for second-level domain names, like
example.com
, and instructs the Recursive Resolver to pass the request along to the appropriate Authoritative Nameserver. - The Authoritative Nameserver looks up
example.com
’s IP address (let’s say,192.0.2.0
) and returns it to the recursive resolver, which finally sends the information to the browser.
Thanks to DNS, the browser now knows to send the user’s example.com
request to 192.0.2.0
, where the web server will receive it.
The Web Server Response
The web server’s job is to receive the request, fetch any necessary content, and send a response back to the browser:
- Processing the request: The web server receives the request and interprets it (for example, is it a
GET
request? or aPOST
request?). It checks if the requested content is static (like HTML) or whether it requires dynamic generation (like PHP or Python). - Fetching or generating content: The server retrieves the requested content. If it’s dynamic content, the server also processes the request using backend languages, connects to databases if needed, and generates the appropriate response.
- Sending the response to the browser: Once the content is ready, the server wraps it in an HTTP or secure HTTPS response and sends it back to the browser.
After all of these steps, which usually take a fraction of a second, the browser renders the requested content from example.com
for the user.
So, What is a Web Server?
A web server is a collection of specialized software installed on a physical server (a machine similar to your computer at home) that listens for incoming requests from browsers. These requests are usually made via the HTTP or HTTPS protocols and could involve fetching static files like HTML, CSS, and JavaScript, or processing dynamic data.
Let’s look more closely at these ideas.
Key Components of a Web Server
A “web server” essentially consists of three things: a physical computer or virtual machine, an operating system, and web server software.
- The physical computer or virtual machine acts as the foundation of the web server, providing computing resources (CPU, RAM, storage) and network connectivity to support web hosting. The resources can be dedicated to a single user or shared with several users.
- The underlying operating system (OS) manages hardware resources and provides a platform for other components in the system. These components, plus the OS itself are also called a “stack.” Common choices for OS include Linux and Windows Server. Linux is the most popular, well-known for its stability and flexibility in server environments. The majority of web servers use some variant of Linux, like CentOS or Ubuntu.
- The web server software handles the incoming HTTP/HTTPS requests. In response, it serves static content or forwards dynamic requests to an application server. Common web server software includes Apache HTTP Server, Nginx, and LiteSpeed Web Server. We’ll talk more about these later.
Static vs. Dynamic Content
Let’s look at the different types of content that may be requested from a web server:
- When the web server receives a request for static content, it directly delivers pre-existing files to the browser without any modifications. It’s fast, because the server only has to retrieve and serve the file. Popular types of static content include HTML, CSS, and images.
- Dynamic content requires additional server-side processing time before the response can be sent to the browser. In a nutshell:
- The web server runs an application server script. This could be in PHP, Python, or some other language.
- The script may talk to a database to get specific information, such as user details, or search results, depending on the request.
- The server generates a custom HTML page tailored to the user’s request.
- The server sends the generated page back as static HTML to be displayed in the user’s browser.
Additional Web Server Features
This is the basic behavior of a web server: to receive a request, process it, and respond with the requested content. But there are other features that a web server provides, including security and performance enhancements.
Security Features
Web servers can support a number of security features, but the two most popular are Web Application Firewall (WAF) and Secure Socket Layers (SSL) / Transport Layer Security (TLS) Encryption. These important features are not built into web servers, per se, but good servers support them.
A WAF, usually in conjunction with a server’s security module, monitors incoming traffic, inspects each request, and uses a set of rules to block anything suspicious. This helps prevent hacking attempts and traffic overload attacks like Distributed Denial of Service (DDoS) attacks.
SSL and TLS encrypt the data that is exchanged between your browser and the web server, keeping sensitive information like passwords and payment details safe from hackers. When you see https
in the address bar, you know that the server is using SSL/TLS to create a secure connection, scrambling data so that only the right people can read it.
SSL and TLS protect personal information from being intercepted, ensure data isn’t altered during transmission, and confirm the website is genuine. SSL support is built into the web server, but it uses certificates that are generated externally via a Certificate Authority (CA) like Let’s Encrypt.
Performance Features
In addition to security, web servers provide important performance features, such as compression and caching.
Web servers use GZIP, Brotli, and other technologies to compress the size of files sent from the server, making them faster to download. The browser decompresses the files upon receipt. This saves bandwidth and decreases page load times, a boon for users with slower connections.
A cache is used to store static copies of frequently requested dynamic content. Web servers that make use of caching, serve the static copies rather than regenerating the dynamic content each time it is needed. This significantly reduces server workload, saves resources, improves load times and provides a better user experience.
Common Web Servers
Let’s take a look at a few popular Linux-based web servers, and see what sets them apart from each other.
Apache
Apache HTTP Server was launched in 1995, and is one of the earliest web servers. Still widely used today, Apache was developed as an open-source project, and gained popularity for its flexibility and ability to run on multiple platforms, such as Linux and Windows.
Apache revolutionized web hosting by making it accessible and customizable. Its modular design attracted users who were able to adapt the server for a wide range of web-based applications. Even today, Apache powers millions of websites worldwide.
Nginx
Nginx was released in 2004 by Igor Sysoev, and was designed to solve the problem of handling ten thousand concurrent connections efficiently. This is also known as the C10k Problem. Nginx’s lightweight, event-driven architecture made it an attractive choice for high-traffic websites.
Known for its high performance, scalability, and low resource usage, Nginx excels at serving static content and handling a large number of simultaneous connections. It’s often used as a reverse proxy and load balancer in front of Apache servers, as it is better at efficiently handling heavy traffic than Apache tends to be.
LiteSpeed Web Server
LiteSpeed Web Server was launched in 2003 by George Wang. It was designed for speed and efficiency, developed to address the performance limitations of traditional web servers like Apache. LiteSpeed Web Server offers seamless Apache compatibility and significantly better performance, especially for dynamic content and SSL handling. Its compatibility with Apache configurations allows for easy migration, making it attractive for users seeking better performance without reconfiguring their entire setup.
LiteSpeed is known for its speed, resource efficiency, and robust security features. It excels in server-side caching, and is a go-to solution for web hosts prioritizing speed, security, and scalability.
Conclusion
We hope this overview has given you a sense of what web servers do, in general, and the vital role they play in the functioning of the internet. Visit our website if you’d like to learn more about LiteSpeed Web Server in particular!
Comments