You all must be familiar with the internet. Have you ever thought of how your request fetches the desirable result? If you want to understand the idea, this blog is for you. Here we’ll discuss the concept behind the client-server model and how it works. So let’s get started.
The client-server architecture is a distributed application framework consisting of clients and servers in which server hosts, manages, and delivers client services. Clients are connected to a central server, and they communicate over internet connection through computer network. Whenever client needs any service, it sends a request to servers, which process the request and return response to the client.
Healthcare application: A client computer can be running an application to enter patient information. At the same time, a server computer can be running another code to retrieve and manage the database system.
Banking application: When a bank customer accesses banking services with a web browser (the client), client initiates a request to the webserver. Customer's login credentials can be stored in a database, and webserver accesses database server as a client. Application server process the returned data by applying the business logic of banking application and provide output to the webserver. Finally, webserver returns the result to the client (web browser) for display.
Similarly, various applications such as email, the World Wide Web, and network printing use client-server architecture.
There are four components required in client-server architecture: Client, load balancer, servers, and network-layer protocols. Let’s discuss them in detail:
Server: A software that receives and processes requests from clients. It usually operates on a remote machine and can be accessed by a user’s local computer or workstation. A client can use a server to share resources and distribute tasks. Example: Webserver
Load balancer: Responsible for distributing incoming requests across a group of servers to manage traffic and optimize resource usage.
Client: A computer application that takes the input and sends requests to the servers. It runs on a user’s local computer/remote machines and connects to a server. They are software application that requests resources and services made available by a server. Example: Web browser
Network protocols: The client-server model follows a request-response messaging pattern. It communicates using the typical TCP/IP protocol suite, which distributes the application data into packets that networks can deliver and manages flow control. Once connection is established in TCP protocol, it is maintained until client and server have completed the message exchange. While IP is a connectionless protocol in which each independent unit of data is unrelated to any other data units and travels through the internet.
The data flow is unidirectional, which forms a cycle. It is initiated when a client requests some data, and server processes the request and sends some sort of data back to the client via a protocol. Clients cannot directly talk to each other.
Data flow in a client-server architecture will look like this:
To better understand the data flow in a client-server architecture, let’s explore how browser (Client) interacts with servers?
Here are some major differences between peer-to-peer and client-server architecture:
Centralised Management: Client server architecture is a centralised network of systems with all data in a single place, with complete leverage to control processes and activities. One can easily share resources and data across various platforms, and users have the authority to access any file residing in the central storage at any time.
Flexibility: Since data being passed between the client and server and server services are entirely up to the programmer. So there could be several ways to use client-server architecture to solve problems that may arise in the future. It can also be easy to combine with other types of architecture on the client or server sides.
Extensibility: The system can be updated based on changes in functional and non-functional requirements without altering the client-server architecture or disrupting service.
Transparency: Clients only make requests to the server with their input data, so they don’t see how servers will handle the request. It may seem like a single, central server for a user.
Availability: Most of the time, servers do not need to shut down or restart for a long duration. So server uptime is possible during maintenance with server duplication. On another side, there is a clear separation between clients and servers because clients are consumers, and servers are service providers. If several servers offer the same services, system can still function if one or more servers fail.
Scalability: Capable of adding or removing servers in the network (Horizontal scaling) or migrating to larger and faster server machines (Vertical scaling).
In this blog, we have covered fundamental concept behind the client-server architecture, how it works and how client-server architecture can be an efficient way of interaction. Hope you enjoyed this blog. Please share your views in the message below.
Enjoy system design, enjoy algorithms!
Subscribe to get weekly content on data structure and algorithms, machine learning, system design and oops.