Web Server - Codelivly
Web Server - Codelivly
Servers
2
But what exactly is a web server? Think of it as a digital butler. When you ask for a
webpage—by clicking a link or typing in a URL—the server jumps into action, fetches the
content you asked for, and serves it back to your browser. Fast, silent, and mostly
invisible.
Despite their quiet presence, web servers do a ton of heavy lifting. They handle
requests, serve up websites, enforce security, and connect with databases and APIs.
They're the gatekeepers of the web—making sure the right content gets to the right
people, at the right time.
At its most basic level, a web server is a special kind of software (and sometimes
hardware too) that delivers web pages to people’s browsers when they ask for them.
<https://www.example.com>
What you’re really doing is sending a request across the internet that says:
A web server receives that request, finds the right file on the server (usually something
like index.html), and sends it back to your browser so it can display the page.
Behind all of this is a protocol called HTTP (HyperText Transfer Protocol), which defines
how these messages are structured and how the server and client should talk to each
other.
You can run multiple web server applications on a single machine—or just one.
The #1 job: accept incoming requests from browsers and respond with the correct
content—like HTML pages, images, CSS stylesheets, or JSON data.
Dynamic responses usually involve backend languages like PHP, Python, Node.js, etc.
The web server either processes it or forwards the request to another service to
generate the output.
3. Managing Resources
Web servers are smart enough to handle multiple users at once, manage traffic
efficiently, and make sure nobody hogs all the bandwidth. They often support
5
When you see the little lock 🔒 icon in your browser, that's thanks to HTTPS, which is
HTTP + SSL/TLS encryption. The web server plays a big role in setting this up by:
Every request that hits the server is logged. This is useful for:
Web servers can control what happens when users visit different URLs. For example:
In more complex setups, web servers can act as reverse proxies—sitting in front of
application servers and forwarding requests. They can also distribute traffic across
multiple backend servers, which improves performance and reliability.
Sometimes, it just grabs pre-made sandwiches (static files), and other times it has to
wait for the chef to cook something fresh (dynamic content). Either way, it makes sure
you get what you ordered.
And the best part? You can set one up yourself in less than 10 minutes with just a few
commands. Whether it’s for a personal blog or a global e-commerce site, web servers
are the backbone of it all.
Let’s introduce the internet’s power couple: the Client and the Server.
+ 🖥 = Client-Server Model
7
The Client-Server Model is the basic way the web works. It’s like a two-person
conversation:
● The client is you—well, technically, it’s your browser (Chrome, Firefox, Safari,
etc.).
● The server is the web server that hosts the website or web application.
The server replies, “Sure, here you go!” (or sometimes, “Sorry, I can’t find that.”)
2. Your browser looks up the domain name through DNS (Domain Name System)
and finds the server’s IP address.
3. Your browser sends a request to the web server—usually an HTTP request that
says:
“GET me the homepage!”
4. The web server receives the request and checks its files.
6. Your browser unpacks the response and shows you the tasty cake website.
This whole thing takes less than a second. (Unless you’re on hotel Wi-Fi... then, good
luck.)
8
● When you open localhost on your laptop to test a web app, your machine is
both client and server.
● In multiplayer gaming, your computer might act as the server for others.
But in web terms, we usually talk about a client as the one asking, and the server as the
one responding.
That means every time you send a request, it’s like a fresh conversation. The server has
no memory of what you did a minute ago unless you give it tools to remember.
Logging into Gmail Your phone or Google’s mail server handles your login
PC
Buying shoes online Your device The store’s server shows the product and
processes payment
It’s happening around you all day, every day—even when you don’t realize it.
● Browse websites
● Watch videos
● Play games online
● Send messages to friends
And the best part? It’s simple at its core—one side asks, the other side responds.
Once you understand this model, everything else in web development starts to click into
place.
10
To understand how far web servers have come, let’s take a little time-travel trip, starting
from the '90s all the way to modern-day cloud computing.
At a research lab in Switzerland called CERN, a brilliant guy named Tim Berners-Lee
had an idea: what if researchers could easily share documents using something called
hypertext? That idea led to the invention of the World Wide Web.
And to make it work, he created the first-ever web server on a NeXT computer (yes,
that’s the company Steve Jobs started after leaving Apple). The software was called
simply:
It could handle basic HTTP requests and send back static web pages (just text and
hyperlinks, no images yet!). The very first website? It explained what the web was and
how to use it. Simple. Revolutionary.
Apache quickly became the go-to web server for developers and businesses. Why?
For years, Apache powered the majority of websites on the internet. If you made a
personal blog or small business site in the 2000s, chances are it was running on
Apache.
Instead of creating a new thread for each user (like Apache), Nginx used an
event-driven model, meaning it could serve thousands of users with just a few
resources.
Companies like Netflix, Airbnb, and Dropbox started using it. It became the go-to
solution for high-performance websites.
IIS was deeply integrated with Windows Server and worked seamlessly with
technologies like:
● ASP.NET
● Microsoft SQL Server
12
● Active Directory
If a company was already running Windows infrastructure, IIS was a natural choice. It’s
still widely used in enterprise environments, especially for internal apps and
Microsoft-based stacks.
Fast forward to today. Web servers are still critical, but now they live in more dynamic,
flexible environments. Here’s what’s new:
🌩 Cloud-Native Servers
● Hosting has moved to platforms like AWS, Azure, and Google Cloud.
● You can spin up a full web server in seconds using tools like EC2, Lightsail, or
App Engine.
⚙ Serverless Architectures
● With services like AWS Lambda, you don’t even need to manage a web server
anymore.
● You just write a function, upload it, and it runs whenever someone makes a
request.
● No patching, no scaling, no infrastructure.
🎯 Final Thoughts
Web servers have evolved from simple text-file fetchers to powerful, cloud-based
engines that drive modern applications.
And while the names and tools have changed, the goal remains the same: get content
from point A (the server) to point B (the user)—as fast, safely, and reliably as possible.
14
Modern websites and apps are built like well-oiled machines, with many moving parts
working together. And the web server? It’s smack in the middle of it all—the coordinator,
the gatekeeper, and the messenger.
Web architecture is how all the parts of a web app are structured and connected—like
the blueprint of a house, but for websites.
It:
Static Images, CSS, JS, HTML Served directly from disk by the web server
So, the web server either acts like a waiter bringing a dish from the kitchen, or like a
messenger relaying your order to the chef (backend app).
The web server acts as the traffic controller, directing requests to the right backend
system.
🗂 4. Connecting to Databases
Web servers themselves don’t usually talk directly to databases like MySQL or
PostgreSQL. Instead, they pass requests to backend apps, which then talk to the
database, fetch the data, and send it back.
But the web server still plays a vital role in this dance by:
Example:
● CDN handles the heavy lifting of media files and static content
This offloads work from your main server and speeds things up for global visitors.
In short: it’s the first line of defense before a request even touches your app.
● CDNs
● Firewalls
● Caching layers
● Microservices
● APIs
Through all of this, the web server is always in the middle—coordinating, delivering,
securing, and optimizing.
18
Choosing the right web server is kind of like choosing the right tool for a job.
● If you’re building a simple blog, you might want something lightweight and easy
to set up.
● If you’re hosting a massive streaming platform or a banking app, you’ll need
something fast, secure, and scalable.
Over the years, several types of web servers have become popular in the tech world,
each with its strengths, quirks, and best-fit scenarios. Some are open-source and
community-powered, while others are proprietary and built into specific ecosystems
(like Windows).
By the end of this chapter, you'll have a solid understanding of what each server brings
to the table—and which one might be the best fit for your project or organization.
19
Do I go open-source or proprietary?
This isn’t just a licensing decision—it can affect how much control you have, how much
you pay, how you configure and scale, and even how fast your team can troubleshoot
problems.