DEV Community

loading...
Cover image for Client-Server Model

Client-Server Model

Mahmoud EL-kariouny
Full Stack Web Developer
・2 min read

What is the Client-Server Model?

⦁ In order to build database-backed web applications, we first need to understand how servers, clients, and databases interact.

⦁ A server is a centralized program that communicates over a network (such as the Internet) to serve clients.

⦁ And a client is a program (like the web browser on your computer) that can request data from a server.

⦁ When you go to a web page in your browser, your browser (the client) makes a request to the server—which then returns the data for that page.

Relational Database Clients :

⦁ A database client is any program that sends requests to a database.

⦁ In some cases, the database client is a web-server! When your browser makes a request, the web server acts as a server (fulfilling that request)

⦁ But when the web server requests data from the database,

  • It is acting as a client to that database—and the database is the server (because it is fulfilling the request).

Servers, Clients, Hosts :

⦁ In a Client-Server Model, a server serves many clients.

⦁ The Client can be (Commands line Applications, Graphical users interfaces, Web App).

⦁ Servers and clients are programs that run on hosts.

⦁ The server sometimes refers to both the computer and the process that serves the web app

⦁ Hosts are computers connected over a network (like the internet!).

⦁ The host (computer) of the web server and the database, can be the same computer.

Requests and Responses :

⦁ A client sends a request to the server

⦁ The server's job is to fulfill the request with a response it sends back to the client.

⦁ Requests and responses are served via a communication protocol, which sets up the expectations and rules for how the communication occurs between servers and clients.

Note:

Don't let this confuse you.
Basically, we call things clients when they are making a request and servers when they are fulfilling a request.

Since a web server can do both, it sometimes acts as a server and sometimes acts as a client :).

Discussion (0)