Client-Server Architecture

Nehal AdilNehal Adil
8 min read

Remember playing catch as a kid? One person throws the ball, and the other catches it and throws it back. That's surprisingly similar to how the internet works. In the digital world, we call this back-and-forth the server-client architecture, and it's the backbone of nearly everything you do online.

Let's say you want to access a research paper published by Stanford University, and the paper is stored in their system or database. You could ask them to mail it to you, which might take weeks. To address this issue, we use a network that connects your computer to their server. This system or architecture is known as Client-Server Architecture, where your computer acts as the client and their computer serves as the server.

What is Server-Client Architecture?

At its core, server-client architecture is just two computers talking to each other. One computer (the client) asks for something, and another computer (the server) responds. It's like a restaurant: you're the client placing an order, and the kitchen is the server preparing and delivering your meal.

Your web browser is a client. When you type "google.com" into your address bar, your browser is essentially raising its hand and saying, "Hey, can I get Google's homepage?" Somewhere in a data center, a Google server receives this request and sends back the webpage you see.

Advantages of the Client-Server Model

  • Centralized System: All data is stored in a single location.

  • Cost Efficient: Requires less maintenance cost and data recovery is possible.

  • Scalability: The capacity of the clients and servers can be adjusted separately.

Disadvantages of the Client-Server Model

  • Security Risks for Clients: If viruses, Trojan horses, and worms are present on the server or uploaded to it, clients are vulnerable to them.

  • Server Vulnerabilities: Servers are prone to Denial of Service (DOS) attacks.

  • Transmission Threats: Data packets can be spoofed or modified during transmission.

  • Phishing and MITM Attacks: Phishing or capturing login credentials and other useful user information is common, as are Man-in-the-Middle (MITM) attacks.

Role of Protocols in Communication

TCP/IP is a set of rules (protocols) used by computers to communicate with each other.

TCP (Transmission Control Protocol) is a connection-oriented protocol, which means it establishes and keeps the connection open until the data exchange is complete. Here's what TCP does:

  • Decides how to break application data into smaller pieces (packets).

  • Sends these packets to the network layer and receives packets from it.

  • Manages the flow of data to ensure it doesn't get too fast or too slow.

  • Resends packets if they get lost or mixed up.

  • Acknowledges each and every packet that enters the network.

TCP operates partly on Layer 4 (Transport Layer) and Layer 5 (Session Layer) of the OSI model, which stands for Open Systems Interconnection. The OSI model is a framework used to understand how different network protocols interact.

Types of Client-Server Architectures

  1. 1-Tier Structure

In a 1-tier architecture, the user interface, business logic, and data logic are all on the same system. Because the client and server are on the same system, the environment is straightforward and inexpensive, but the variation in the data necessitates repetitive effort. These systems keep their data in a shared driver or a local file. The MP3 player and MS Office files are two examples of 1-tier apps.

  1. 2-Tier Structure

Due to the lack of a server in between, the 2-tier design offers the greatest performance environment. The database is on the server side, while the user interface is on the client side. The database and business logic can be stored on both the client and server ends.

The design is known as a fat client-thin server architecture if both sit at the client end. On the other hand, the design is known as a thin client-fat server architecture if both sit at the server end. A two-tier architecture is typically used in online ticket reservation systems.

  1. 3-Tier Structure

A middleware is a component of the three-tier architecture that facilitates communication between the client and the server. Despite being pricey, it is quite simple to use. The middleware enhances flexibility and performance. The data logic and business logic are stored there. The 3-tier architecture’s three layers are:

  • (Client tier) Presentation Layer

  • (Business tier) Application Layer

  • (Data tier) Database Layer

In almost all cases, a 3-tier design is used in online applications.

  1. N-Tier Structure

The scaled-down version of the three-tier architecture is the n-tier architecture. The processing, data management, and presentation functions are separated into distinct layers in such a setting. The system is simple to run and maintain because of the isolation. This also goes by the name of “multi-tier architecture.”

HTTP Request-Response Cycle

HTTP (Hypertext Transfer Protocol) is the language clients and servers use to communicate. Think of it as the rules of polite conversation, but for computers.

When you click a link or type a URL, your browser creates an HTTP request. This request includes:

  • What you want (GET, POST, PUT, DELETE)

  • Where to find it (the URL)

  • Any extra information (like cookies or form data)

The server then sends back an HTTP response containing:

  • A status code (200 for success, 404 for "not found," etc.)

  • The requested data (usually HTML, images, or other files)

  • Additional information (like the type of content being sent)

For example, when you log into Facebook, your browser sends a POST request with your username and password. Facebook's servers check this information and respond with either your news feed (success) or an error message (failure).

Here's how the HTTP request-response cycle works:

1. Client Initiates Request

The cycle begins when a client (such as a web browser) makes an HTTP request to a server. This request can be for a webpage, image, file, or any other resource.

2. DNS Lookup

Before the request can reach the server, the client performs a DNS (Domain Name System) lookup to translate the domain name (e.g., www.example.com) into an IP address that identifies the server.

3. TCP Connection

The client establishes a TCP (Transmission Control Protocol) connection with the server using the IP address obtained from the DNS lookup. This connection ensures reliable communication between the client and the server.

4. HTTP Request

The client sends an HTTP request to the server over the established TCP connection. The request typically includes:

  • HTTP Method: Defines the action to be performed (e.g., GET, POST, PUT, DELETE).

  • URL: Specifies the resource being requested.

  • Headers: Provide additional information such as the user-agent, cookies etc.

5. Server Processes Request

The server receives the HTTP request and processes it. The server performs tasks such as:

  • Authentication and Authorization: Verifying the client's identity and access permissions.

  • Fetching Data: Retrieving the requested resource from a database or file system.

  • Business Logic: Executing any necessary business logic (e.g., calculations, data processing).

6. HTTP Response

After processing the request, the server generates an HTTP response. The response typically includes:

  • Status Code: Indicates the outcome of the request (e.g., 200 OK, 404 Not Found, 500 Internal Server Error).

  • Headers: Provide additional information such as the content type, etc.

  • Body: Contains the requested resource or data (e.g., HTML content, JSON data, image file).

7. Client Receives Response

The client receives the HTTP response from the server over the TCP connection. It interprets the status code and headers, and processes the response body accordingly.

8. Rendering or Processing

The client renders the received content (e.g., displaying a webpage) or processes the data (e.g., handling JSON data in a web application).

9. Closing the Connection

In most cases, the TCP connection is closed after the response is received. However, for persistent connections (keep-alive), the connection may be reused for subsequent requests.

Hosting: Finding a Home for Your Website

Website hosting is like renting space for your website to live. When you build a website, those files need to exist somewhere that's always connected to the internet. That's where hosting comes in.

There are several types of hosting:

  • Shared hosting: Your website shares a server with others (like living in an apartment building)

  • VPS (Virtual Private Server): You get your own portion of a server (like having a townhouse)

  • Dedicated hosting: You get an entire server to yourself (like owning a standalone house)

  • Cloud hosting: Your website lives on multiple connected servers (like having homes in different cities)

Conclusion

The server-client architecture is the invisible engine driving the modern web. By distinguishing client-side tasks (UI, user interactions) from server-side operations (data processing, security), developers create seamless digital experiences. The HTTP request-response cycle ensures efficient communication between these two realms, while web servers and hosting providers make global accessibility possible. Whether you’re building a personal blog or a multinational platform, mastering these concepts is the first step toward leveraging the web’s full potential.

As technology evolves, the fundamentals of server-client dynamics remain timeless—proving that even in a world of cutting-edge innovations, the basics still matter.

Server-client architecture isn't going anywhere, but it is evolving. Modern approaches like serverless computing and edge computing are building upon these fundamental concepts. However, understanding the basics of server-client architecture will always be valuable, as it forms the foundation of how we interact with the internet.

Whether you're building your first website or just curious about how the internet works, remember this: every click, every search, every like button pressed is just another game of catch between clients and servers, playing out at the speed of light across the global network we call the internet.

0
Subscribe to my newsletter

Read articles from Nehal Adil directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Nehal Adil
Nehal Adil