The Fundamentals of Web Servers: Understanding How They Work. A web server is a computer hardware or software that stores websites and serves them over the internet to end users. It receives HTTP/ HTTPs requests and sends back structured content, whether text, image, or video. Basically, all websites are located in different servers located all over the world. By utilizing the HTTP protocol, a web server processes the request and deliver the response back to web browsers such as Mozilla, Edge, Opera, Chrome, and more.
When a user types in a URL in their browser, several actions happen, including a DNS lookup, HTTP request, and content delivery. This article discusses the fundamentals of web servers, including how they work, different types, and the components that make up a web server.
Shall we start article The Fundamentals of Web Servers: Understanding How They Work?
How a Web Server Works
A software web server is quite different from a physical web server. However, at its core, it performs the same function as a physical web server, but with extra functionalities. The software program runs on physical computers, mimicking the functionality of the hardware. Apache, Nginx, HAProxy, and IIS are examples of software web servers.
Receiving HTTP Requests and Serving Web Content
When a user types open a URL via their browser, the browser sends an HTTP request through the internet. First the browser looks at the requested IP address in the Domain Name System (DNS), as each domain has a unique IP address associated with it. The browser locates the server where the website is located.
The server receives the HTTP request and processes it through its HTTP server, which then accepts the request. Once the request is received, it searches through the server where the files are located. Once it locates the files, it sends back a request. When the HTTP server fails to locate the requested files, it sends back a 404 error, or a 403 error when access permission is limited.
Types of Web Servers
There are two main types of web servers:
On the other hand, a dynamic web server provides content that’s subject to change based on user input. Most of these web servers use languages such as ASP.NET, Node.js, or PHP to generate HTML content on the go. This helps developers to create interactive experiences as the server responds to user inputs in real time.
Understanding Web Server Architecture
Web server architecture is basically the layout or pattern of interaction of a web server. These include all the essential components such as configurations, design, and elements that the web server needs to deliver web based services and operations. There are a specific set of parameters used to define web server architecture ,such as:
- Physical capabilities – processing power, storage, and memory.
- Efficacy and performance – memory consumption, throughput and latency.
- Application layers – applications that sit on the server.
- Supported operating system
- Internet or network connectivity
There are two main approaches to web server architecture:
The concurrent approach enables a server to handle many requests at a go as it assigns individual threads to handle user requests. This method handles I/O in a synchronous/non-blocking manner. The concurrent approach is supported by a lot of programming languages .
Additionally, it’s a very intuitive approach as it allows you to sequentially program all the tasks you need to handle user requests. The concurrent approach uses a thread-based model, but for it to achieve true concurrency it needs to use multiple threads simultaneously.
The multi-process method employs a process-per-connection strategy. One dedicated parent thread generates multiple single threaded child processes. The parent process then assigns all incoming connections to individual child threads.
Each child process only handles a single user request at a time. Since the child processes do not share memory, multi process servers are able to isolate and execute multiple requests quickly. The heavy nature of these processes reduces the amount of simultaneous connections achievable. Basically, the multi process model sacrifices memory in order to achieve concurrency.
A multithreaded server is designed to handle multiple requests simultaneously. This type of architecture processes web requests in parallel. This model also uses a thread-per-connection strategy, but with a few variations. First the threads all share a common address space. This enables the server to apply common features across all request handlers that are inside the server. The threads in the multithreaded model are also lighter and hence consume less data.
This approach combines the single threaded and the multithreaded models. In an hybrid approach, the server generates multiple processes that in turn initiate multiple threads. Using multiple threads in single processes reduces burden on CPU and RAM.
2. Single Process Event Driven Approach
Components of a Web Server
The processor or the Central Processing Unit (CPU) is basically the brain of the server. It is a sophisticated micro-circuit component that functions as the basis for all computer operations. The CPU responds to hundreds of possible commands that are written into millions of transistors to process microcode and data and compute the target logical result. The processor works in conjunction with memory, as the memory contains the commands, data, as well as the results of those computational operations.
The processor reads and runs the simple functions of a computing system such as write back, decode, fetch and execute. The four major parts of the CPU are the cache memory, registers, arithmetic logic unit (ALU) and the floating point unit (FLU). On a much smaller scale, the ALU runs all arithmetic and logic commands.
Random Access Memory (RAM) is the short term memory that stores data currently working with the processor. RAM connects software elements and hardware and its read/write performance speed is better than some conventional data storage methods. Memory volatility defines how much data the RAM loses when the computer shuts down. Your web server needs non-volatile storage for data when you switch off or restart your system.
Storage is basically a physical data store that stores all files, operating systems, libraries, and website data. Traditionally, web data was stored in hard disks, but recently, solid state drives (SSD) have become mainstream, although they are more expensive. In the event the storage device fails, all websites hosted on the web server become unavailable. To avoid this, most servers have a Redundant Array of Independent Disks (RAID) to minimize downtime.
4. Network Connection/ Bandwidth
Web servers only work when connected to the internet, which is possible through a combination of networks. This means that a minimum of one network connection has to occur to maintain communication between a data center local area network and the web server. If you need a fast web server, you must equip it with high bandwidth. If the website is hosted on smaller bandwidth, it’s difficult for users to access the website.
Thank you for reading The Fundamentals of Web Servers: Understanding How They Work. We shall conclude the article now.
The Fundamentals of Web Servers: Understanding How They Work Conclusion
All in all, web servers enable users to host website and server web content. Without web servers, a website cannot be served on the World Wide Web. The construction of the web server affects the website’s search performance and overall user experience. Therefore, you need a well configured web server with all the essential components working seamlessly together to be able to serve the requested content.