Networking for Backend Engineers
Understand essential networking concepts backend engineers need for reliable service communication and troubleshooting.
Why Networking Matters for Backend Engineers
Backend systems do not operate in isolation. Most backend functionality depends on machines communicating across networks.
- Backend services exchange data with other systems over networks.
- Every API request involves communication between machines.
- Network conditions often influence system performance and reliability.
Details
Backend systems are designed to receive requests, execute logic, and return responses. In practice, those requests usually originate from other machines, not from the same computer where the backend is running.
When a user interacts with a web or mobile application, their device sends a request across the internet to a remote server. That request travels through multiple networking components before reaching the backend application.
Backend systems also communicate internally. One service may call another service, query a database server, or send requests to external APIs. These interactions all occur across a network.
Because of this, many system issues originate from networking behavior rather than application code. Slow API calls can be caused by network latency, dropped connections may interrupt requests, and retries often occur when responses fail to arrive in time.
Understanding how machines communicate across networks helps engineers reason about system performance, reliability, and failure scenarios in distributed systems.
How a Request Reaches a Server
Before backend code can process a request, the client must locate the server, establish a network connection, and send the request through several infrastructure layers.
- Clients first resolve a domain name into a server’s IP address using DNS.
- A TCP connection establishes a reliable communication channel between machines.
- Infrastructure such as load balancers routes the request to a backend server.
Details
When a client application sends a request to a backend system, several networking steps occur before the backend code even begins executing.
The process typically begins with a domain name such as api.example.com. Computers cannot directly communicate using domain names, so the client first performs a DNS lookup to determine the IP address of the target server.
Once the IP address is known, the client establishes a TCP connection with that machine. This connection creates a reliable channel for sending data between the client and the server.
After the connection is established, the client sends an HTTP request. This request contains the method, headers, and any data needed by the backend system.
In modern architectures, the request often passes through a load balancer before reaching the application server. The load balancer decides which backend machine should handle the request, helping distribute traffic across multiple servers.
Finally, the request arrives at the application server where the backend application processes it, executes business logic, and generates a response that travels back to the client.
DNS (Domain Name System)
DNS converts human-readable domain names into IP addresses so computers can locate servers on a network.
DNS resolves names to IPs. Caching (shown in loop 2) speeds this up significantly.
- Domain names provide a human-friendly way to identify services.
- DNS resolves domain names into the IP addresses of servers.
- Caching reduces lookup time by storing previously resolved results.
Details
Computers communicate with each other using numerical IP addresses such as 142.250.72.14. However, humans interact with services through domain names like api.example.com because they are easier to remember.
The Domain Name System (DNS) acts as a distributed directory that maps these domain names to their corresponding IP addresses. When a client wants to contact a server using a domain name, it sends a DNS query to determine the correct IP address.
This lookup process may involve several DNS servers working together. The system eventually returns the IP address associated with the requested domain so the client knows where to send the request.
To improve efficiency, DNS responses are often cached by operating systems, browsers, and intermediate servers. If a recent lookup already exists in the cache, the system can reuse the stored IP address instead of performing a new DNS query.
DNS is a foundational component of internet infrastructure. Without it, users and applications would need to remember and manually manage numerical IP addresses for every service they interact with.
Ports and Network Endpoints
An IP address identifies a machine on the network, while a port identifies the specific service running on that machine.
- The IP address tells the network which machine should receive the request.
- A port directs the request to the correct service on that machine.
- Multiple services can run simultaneously on a single host using different ports.
Details
Once a client knows the IP address of a server, it still needs to determine which application on that server should handle the request. This is where ports are used.
A port is a logical communication endpoint on a machine. While the IP address identifies the host itself, the port identifies the specific service listening for incoming connections.
For example, a web server typically listens on port 80 for HTTP traffic or port 443 for HTTPS traffic. Databases and other services also use well-known ports. PostgreSQL commonly listens on port 5432, while Redis often runs on port 6379.
Because ports separate services, a single machine can run many different applications simultaneously. A backend server might host an HTTP API, a database, and a caching service at the same time, each bound to a different port.
Together, the combination of an IP address and a port number defines a network endpoint. This endpoint uniquely identifies where a request should be delivered.
TCP Connections
TCP is a connection-based protocol that ensures reliable, ordered delivery of data between machines.
- TCP establishes a connection between two machines before sending data.
- The protocol guarantees reliable delivery of transmitted packets.
- Packets are reordered if they arrive out of sequence.
Details
Transmission Control Protocol (TCP) is one of the core communication protocols used on the internet. It is designed to provide reliable communication between two machines.
Before any data is transmitted, TCP establishes a connection through a process called the three-way handshake. The client begins by sending a SYN message to the server. The server responds with SYN-ACK to acknowledge the request and signal readiness. The client then sends an ACK message confirming the connection. After this exchange, both machines can begin sending data.
TCP breaks data into smaller units called packets and transmits them across the network. Because networks can drop or reorder packets, TCP includes mechanisms that detect missing data and retransmit packets if necessary.
Another important feature of TCP is packet ordering. Even if packets arrive in a different order than they were sent, TCP reassembles them correctly before delivering the data to the application.
These mechanisms make TCP reliable for applications that require accurate data transfer, such as web requests, database communication, and most API interactions.
TCP vs UDP
TCP prioritizes reliability and ordering, while UDP prioritizes speed and minimal overhead.
- TCP provides reliable, ordered communication between machines.
- UDP sends messages quickly without establishing a connection.
- The choice depends on whether reliability or speed is more important.
Details
TCP and UDP are two major transport protocols used for communication between machines, but they solve different problems.
TCP (Transmission Control Protocol) is designed for reliability. It establishes a connection between two machines, ensures packets arrive successfully, retransmits lost data, and guarantees that packets are delivered in the correct order. Because of these guarantees, TCP is used for applications where accuracy is critical.
Many backend systems rely on TCP. Web protocols like HTTP run on top of TCP, and database connections also typically use TCP because data integrity is essential.
UDP (User Datagram Protocol) takes a different approach. It does not establish a connection and does not guarantee delivery or ordering. Instead, it simply sends packets to the destination as quickly as possible.
Because UDP removes reliability overhead, it is faster and more lightweight. This makes it suitable for applications where occasional packet loss is acceptable, such as real-time video streaming, online gaming, and many DNS queries.
The tradeoff between TCP and UDP is fundamentally about reliability versus speed. Systems choose the protocol that best fits the needs of the application.
HTTP — The Application Protocol
HTTP defines how clients and servers structure requests and responses when communicating over the web.
- HTTP follows a request–response communication model.
- Requests specify actions using HTTP methods such as GET or POST.
- Responses return status codes, headers, and data to the client.
Details
HTTP (Hypertext Transfer Protocol) is the application-layer protocol used by most web systems. It defines the structure of messages exchanged between clients and servers.
Communication follows a request–response model. A client sends an HTTP request describing what it wants to do, and the server processes that request and returns an HTTP response.
Requests include several components. The HTTP method indicates the intended action, such as GET for retrieving data or POST for sending new data. The request also includes headers that carry metadata like authentication tokens, content type, or caching instructions.
After processing the request, the server returns a response. The response includes a status code indicating the result of the operation. For example, 200 OK indicates success, while codes like 404 or 500 signal errors.
HTTP provides the standardized language that allows browsers, mobile apps, and backend services to communicate consistently across the internet.
Latency in Distributed Systems
Network requests take time because data must travel between machines and multiple systems must process the request.
- Data must physically travel across networks between machines.
- Servers need time to process requests and generate responses.
- Additional dependencies such as databases can increase response time.
Details
Latency refers to the time it takes for a request to travel from a client to a server and for the response to return. In distributed systems, even simple operations involve several steps that contribute to this delay.
First, the request must travel across the network. Data moves through routers, switches, and sometimes multiple data centers before reaching the destination server. Geographic distance alone can introduce noticeable delays because signals take time to propagate across long distances.
Once the request reaches the server, the backend system must process it. This may involve running application logic, performing validation, or executing other internal operations.
Many requests also depend on other systems such as databases, caches, or external APIs. Each additional dependency introduces its own processing time and network latency.
Other factors such as network congestion or overloaded services can further increase latency. Because distributed systems rely on many interconnected components, small delays in multiple places can accumulate into noticeable response times.
Timeouts and Network Failures
Distributed systems must protect themselves from slow or failed network requests using timeouts and failure-handling mechanisms.
- Timeouts prevent systems from waiting indefinitely for responses.
- Retries allow systems to attempt a request again after a failure.
- Uncontrolled failures can propagate across services and cause cascading outages.
Details
Network communication is inherently unreliable. Requests may be delayed, connections may drop, and services may fail to respond. Because of this, backend systems must be designed to handle slow or failed network calls safely.
One common protection is a timeout. A timeout defines the maximum amount of time a system will wait for a response. If the response does not arrive within that window, the request is aborted and the system moves on.
Retries are another common strategy. When a request fails due to a temporary network issue, the system may attempt the request again after a short delay. This can help recover from transient failures such as brief network interruptions.
However, retries must be carefully controlled. If many services repeatedly retry failed requests, they can overwhelm downstream systems and create cascading failures where one slow service causes widespread outages.
For this reason, modern backend systems carefully configure timeouts, retries, and failure handling strategies to maintain reliability even when parts of the network behave unpredictably.
Load Balancing
Load balancing distributes incoming traffic across multiple servers so systems can handle higher demand and remain reliable.
Balancer
- A load balancer sits in front of multiple backend servers.
- Incoming requests are distributed across available servers.
- This improves scalability and helps systems remain available if a server fails.
Details
As applications grow, a single server often cannot handle all incoming traffic. To support more users and maintain performance, systems run multiple backend servers that provide the same functionality.
A load balancer acts as the entry point for incoming requests. Instead of clients connecting directly to individual servers, they send requests to the load balancer. The load balancer then decides which backend server should handle each request.
This distribution spreads traffic across servers, preventing any single machine from becoming overloaded. Different algorithms may be used, such as round-robin distribution, least-connections routing, or latency-based routing.
Load balancing also improves fault tolerance. If one server becomes unavailable, the load balancer can route traffic to other healthy servers so the system continues functioning.
This approach enables horizontal scaling, where systems increase capacity by adding more machines rather than upgrading a single server. Horizontal scaling is a foundational strategy for building large, reliable backend systems.
Question Section
1 / 5
This track is locked
Buy this track once to unlock all of its lessons.