Client-Side Vs Server-Side : A Complete Guide For Beginners.

Client-Side Vs Server-Side : A Complete Guide For Beginners.

Often when you heard terms like client and server it hard to distinguish what is the key difference between them because both are software or hardware components that communicate over a network to exchange information. But what's the key difference between them? So in this article you will get a clear picture of how it works and its architecture , will also a real life based analogies to get a complete grasp of it ! 🌐

What is Client ?

Client is a device or application that request resources from the server, basically it means like in our browser when you requests a url from server the browser is called as client but the client can be of following types :

  • Web Browser: Requesting web pages from a web server (e.g., Chrome loading YouTube).

  • Mobile App: Asking for data from an API.

  • Workstation: Connecting to a shared printer.

In short, the client is initiating the conversation to get something done.

What is Server ?

It provides resources to a client. Think of it as the "provider" that fulfills the client’s requests. Some examples include:

  • Web Server: Hosting websites (e.g., Google’s servers delivering search results).

  • Database Server: Storing and serving data.

  • Game Server: Handling multiplayer connections and game states.

Like when you do a freelance work the client specifes you certain requirement in its client and you are the provider that fulfills the reuirement so you are the server that serves the response

How Do Clients and Servers Communicate with Each Other?

The client and the server are the first two obvious participants in client-server communication. Lets understand few keywords that is most often whenever we talk about the communication

  • Requests: Requests are sent from the client to the server to provide information. For example when you want to visit onlyFans you will login using credentials.

  • Response: A server's response to a client request is sent to the client in the form of a message.

  • Service: A service is a specific task that the server makes available to the client, such as an weather API that provides real-time weather data.

Here don’t get confused when i wrote the REST APIs, Modern web services are often based on the REST architecture, which relies on the HTTP protocol and returns data in the JSON format.

In a client-server setup, clients handle tasks like user interaction, while servers manage heavy-duty work like data storage or processing. Communication between them follows rules set by protocols like TCP/IP, ensuring smooth data exchange.

  • TCP keeps the connection alive during a message exchange, handles data packets, and fixes issues like lost packets.

  • When many requests hit the server, it uses a priority-based scheduler to handle them efficiently.

  • Access to the server can be restricted with client access control tools to maintain security.

In short, servers provide resources (like files or data), while clients request and use them.

Real-life Scenarios to understand Client Sever Communication

In your childhood When you wanted anything let say badminton so badminton here is the requested query and you are the client and lets understand each step after this

  • The Client: You, as a child, are the one making the request (e.g., "Papa, mujhe badminton😇").

  • The API: Your mother acts as the API, interpreting your request and passing it to your father in a way he understands.

  • The Server: Your father is the server who processes the request. He decides whether he can fulfill it or not.

  • The Request: "I want Badminton!" is your GET request.

  • The Response:

    • If your father agrees, he sends back a 200 (OK) response along with the badminton.

    • If badminton is not available or he says no, you get a 404 (Not Found) or even a 403 (Forbidden)! 😅

  • The Endpoints: Your mother (API) ensures communication between you (client) and your father (server), so you don't directly interact with the backend logic!

This way, your childhood wish fulfillment was a perfect example of a client-server relationship. Cool, right? 😎

Fun Fact: Peer-to-Peer (P2P) vs Client-Server 🌀

In a peer-to-peer (P2P) model, every device can act as both a client and a server. Think of file-sharing systems like BitTorrent. While the client-server model is hierarchical, P2P is decentralized.

Conclusion

To sum up, the client is the requester, and the server is the provider. They communicate seamlessly to enable everything from browsing the web to playing multiplayer games. With this understanding, the next time you hear "client" and "server," you’ll know exactly who’s doing what!

If you got something valuable from it do give it a like ❤ as it motivates me write more articles

Connect with Me 👇

Github

LinkedIn