Mastering the Client-Server Model and Basic Internet Protocols

A client making a HTTP request to a server and getting the HTTP response diagram.

In a systems design interview, we need to know how the client-server model work to use the right components when designing the system. That’s why we will explore further how this model works since it’s by far the most used in applications. It’s also the foundation of how computers communicate with each other on the internet is the client server model.

Client-server Model Diagram

Before diving through the main concepts of the client-model diagram, let’s have a look on how this works. The client-server model is the way our interactions with websites work. First we will write a URL in the browser and then there will be a request to query the IP (Internet Protocol) address with the DNS (Domain Name System)

client server model diagram

What is IP?

IP (Internet Protocol) is the address of a computer on the internet. Each device has its own unique IP or address so it’s possible to exchange data on the internet.

There are two versions of the IP protocol currently in use: IPv4 and IPv6. IPv4 is the older version and uses a 32-bit address format, while IPv6 is the newer version and uses a 128-bit address format. IPv6 was developed to provide a larger address space to accommodate the growing number of devices connected to the internet.

You can test IP addresses using a tool called “netcat”. To use netcat, you can run the command on the terminal:

nc -l 8081 

Then use the following command in another terminal to connect to the IP address and port:

nc 127.0.0.1 8081
What is a port?

A port is a communication endpoint that allows different processes or services running on a device to send and receive data over a network. Ports are identified by a number between 0 and 65535 and are used to differentiate between different types of network traffic.

Each port is associated with a specific process or service, and when data is sent to a device, the receiving device uses the port number to route the data to the corresponding process or service. Firewalls and network security devices often use port numbers to control access to specific services or protocols.

A port is always used with an IP so we can make an analogy with real physical addresses. The IP will be the street address and the port will be the location number.

What is DNS?

The DNS is a legible name for humans to access websites. Any website name you are able to access on the internet is a DNS, for example, google.com, javachallengers.com are DNS. We could use directly the IP address to access a website but probably no one would remember that.

That’s why a there will be a DNS query to find out the IP address of a website or server because that’s the only way the server will ultimately understand.

To convert a DNS to an IP address, you can use the “dig” command on a Unix-based operating system. You can give a try the following:

dig javachallengers.com

The output will return the IP:

javachallengers.com.	300	IN	A	172.67.169.6
javachallengers.com.	300	IN	A	104.21.27.59

When you send data over the internet using HTTP, you need to specify the port number to be used in addition to the IP address. The IP address is like a street name, and the port number is like a building number.

What is HTTP?

HTTP, or Hypertext Transfer Protocol, is the protocol used for transferring data over the internet. It defines how information is formatted and transmitted between web servers and web browsers, allowing for the retrieval and display of web pages and other online resources. HTTP can be seen as a common language or pattern that computers will understand each other in a network.

When you type a URL into your web browser, the browser sends an HTTP request to the web server hosting the website. The server responds with an HTTP response, which contains the requested resource, such as an HTML document or image file.

HTTP is a stateless protocol, which means that it doesn’t keep track of previous requests or responses. This makes it efficient for transferring small amounts of data, but it can become slow and inefficient for larger data transfers.

HTTP is the foundation of the World Wide Web and is used by millions of websites and web applications every day.

What Applications use the Client-server Model?

The client-server model is a widely used architecture for designing and implementing networked applications, and it is used in a wide range of applications across different industries. Here are some examples of applications that use the client-server model:

Web browsers and web servers: When you browse the internet, your web browser acts as a client, sending requests to web servers to retrieve web pages and other resources. The web servers then respond with the requested content, which is displayed in your browser.

Email clients and SMTP servers: Email clients such as Microsoft Outlook and Apple Mail use the Simple Mail Transfer Protocol (SMTP) to send and receive email messages. The email client acts as the client, and the SMTP server acts as the server.

File transfer applications: Applications such as FTP (File Transfer Protocol) and SFTP (Secure File Transfer Protocol) use the client-server model to transfer files between computers.

Database applications: Database management systems (DBMS) use the client-server model to allow multiple users to access and manipulate a database simultaneously. The DBMS acts as the server, and the client applications send requests to the server to retrieve or modify data.

Online games: Many online games use the client-server model to manage the game state and enable players to interact with each other in real-time.

These are just a few examples of the many applications that use the client-server model.

Conclusion

The client-server model is present everywhere on systems. Understanding the fundamentals of this model is crucial for a systems design interview. The vast majority of the systems you will design in such interview will have the client server model. Sometimes the interviewer will ask you about IP, DNS, HTTP. That’s why it’s fundamental to understand those concepts.

Written by
Rafael del Nero
Join the discussion

2 comments