Client Server Architecture: To the point understanding
Client Server Architecture is a distributed computing model in which a program or application runs on a single computer (the client) and accesses resources (such as files, data, or other services) that are shared by other computers on the network (the server) through the internet via a request response cycle. The client sends a request to the server and the server processes such requests and gives response to the client via the same internet connection. A server processes several requests as well as simultaneous requests on a given time. When you open the facebook app on your mobile which is the client, the app with the login credentials that are stored in your mobile sends a request to Facebook servers to provide the access to your Facebook account and give you the latest feeds. The Facebook server after receiving the incoming request from your mobile and then queries the database and verifies the login credentials and then fetches its database and sends the list of feeds as a response back to your mobile though your internet connection.
History of Client Server Architecture: The origin
The client-server model was first introduced in the 1960s by a group of computer scientists from Stanford Research Institute while designing the ARPANET. It was designed to allow multiple users to access a single computer system simultaneously. In those days, most computer systems were large mainframes that could only be accessed by a few people at a time. The client-server model allowed multiple people to share the resources of the mainframe computer.
Advantages of Client Server Architecture
Some of the major advantages of client server architecture are –
The client server model is an architectural style that allows for separation of concerns between clients and servers. This separation makes it easier to scale applications and maintain code quality.
A client-server system consists of two parts: a server and one or more clients. Clients request services from the server. Servers provide these services to clients.
Client-server architectures offer flexibility, scalability, and security. They also allow developers to build more complex systems than would otherwise be possible with other models.
The client-server model was also used to improve the performance of network applications. By splitting the workload between clients and servers, network applications could run faster and more efficiently.
Client/server systems can provide advantages in performance, reliability, and security. In particular, they can enable faster communication between the client and server, as well as between server components.
Components of client server architecture
With Client/Server architecture the application is separated into parts: the server process and the client process. Some of the components of client server architecture are –
Components that act as client
The client process is meant to make up the user interface (UI), while the server process performs the logical operations.
The physical or the hardware layer – this is basically the device you use like the mobile computer laptop tablet smartwatch etc.
The application layer – this is basically the web browser like chrome safari etc.
The network layer – the internet from where you send the data to the server and the server sends the response back. Your device is able to send data to the server by connecting to the internet.
Components that act as server
The server has several database racks which is the physical layer, is connected with a high bandwidth redundant network which takes in the requests coming through the internet a from a client. The application layer consists of the web server backend operating systems like CentOS, Ubuntu etc. It hosts a REST API which is the more finer layer of the application layer and processes the incoming requests, queries the database and sends response back to the server through the redundant network.
Examples of client server applications: Cut the chase
Here we will examine one of the different examples client server applications. The client process accesses resource information held on client side through the personal computer, mobile, laptop, tablets, smartwatch, etc.
For Ex when you are signing up for an email account.
You enter the details about yourself like name age gender dob alternate email phone number etc. Your device whether its PC laptop or mobile along with the browser you use like chrome safari Firefox opera edge and other browsers act as the client. Your client then sends this data you just entered to the server in this case the email server and the email server stores your data with these details you just entered through the server engine into the database where this information like your name age etc are stored securely and until you willingly delete this data.
Then the server sends a response that whether the information is saved and your account was created or not, if in case your information is saved then you go into the email dashboard, if there is an error it will show you the error, and specifies you what needs to be done. Suppose if there’s a username not available or already taken by anyone it will send you a response that this username can’t be chosen and therefore you need to choose a different username.
You then send data from your client/pc/mobile about another username you wish to choose then the server stores it and then takes you into the dashboard.
When you exit the email account by signing out then the server purpose is fulfilled and the connection with the server (email account server) is closed, and when you close the email account tab from your browser like chorme, Firefox opera safari etc the client’s purpose ends.
With this model, developers have the ability to manage every aspect of the application.
Client-server software architecture is a model in which a computer system is divided into two major components: clients and servers. In this type of system, clients send requests for information or services to servers, which then fulfill those requests. This model has been around for many years and is still in use today.
In this image below consider the client as the mobile, the yellow arrow showing request is sent to the google server over the internet and reaches the google server. The google server then through the internet sends the response(green arrow showing the response) back to your client.
The request response cycle
Here we will examine the request response cycle. Suppose you want to go to google and search for nearby restaurants. Your client sends a request over the internet, in this case you type the URL of google and hit enter in your browser the device/client you are using sends a request to the google server, specifying it in the request that you want to know about nearby restaurants.
The google server instantly searches for the nearby restaurants along with your location data(your current location which was also sent as a part of the request sent to google). It searches in its database engine in their server and as soon as it finds the nearby restaurants it informs you by sending the response containing the list of restaurants, how much is the distance from your locations, what are the timings, what is the address and other relevant data all combined in the response and that response is sent to your client. Then your client which is the web browser displays the response and all the data that was sent such as timings, address, distance etc.
Correlating this architecture with the Http server we built with nodejs in the previous section:
The code that we wrote to create the hello world application via nodejs acts as the REST API which will take the incoming requests from the client and process the request in order to give a response.
Though we have created the node server in our own PC as an example lets assume that after running the node hello world application our PC has become 2 different parts one part acting as a client and one as a server.
In the command prompt or a terminal in the Mac we started our hello world application by giving command “node hello.js” and listens on port 8080. This command started a web server which started listening to port 8080 any request that came from clients.
Then in our web browser we typed url “localhost:8080” and sent our request to the web server to the other logical part of our PC which was acting as a server. The server as soon as listening to a request made from our web browser responded with the “hello world” text into our web browser.
Here the nodejs code we wrote to start the web server acted as a REST API.
What Types of Client Server Software Architecture exist?
API-Based Client Server Architecture
The most common type of client/server software architecture is API-driven (app/service).
Multiple APIs of your software act as connectors between various mobile and web applications.
Here are some more different types of client/server software architecture.
– Web forms. Pretty straightforward and common. Is used to display or collect data in web environment. Like the email account signup we mentioned earlier.
– Drag and drop. Good for collaboration among many functions. Like a website builder where you drag items and position them.
– Online questionnaire. Most widely used customer data collection tool. Some example will be like a company sending a questionnaire through google forms, where your web browser along with the the device(PC/Laptop/mobile) in a combination acts as clients and the google forms where you enter the data acts as the server.
Program data structure. Programmatic API. Local Datastore. it helps explain the event structure of an application. As the app on the client does it operations on the event stream, preferably in chronological order.