Load Balancer vs CDN vs API Gateway

Anvesh
SilentTech
Published in
2 min readDec 3, 2023

Load Balancer: This distributes incoming traffic across multiple backend services.
The goal of load balancing is to ensure that requests for an application or data are spread evenly across the network of servers that hosts the application or data.

A load balancer could be either:
An actual standalone hardware device.
A software application that runs on other networking hardware.

Layer 4 vs Layer 7 Load Balancing
In layer 4 load balancing, the load balancer has limited data information. It only has visibility on network information which is the ports and the IP address of the client.
The load balancer doesn’t really know the content of the data it’s receiving because the data is usually encrypted or scrambled.

In layer 7 load balancing, the load balancer can access the application data and can be authorized to decrypt the data sent through the request.
Based on data (headers, url, etc..,) the load balancer can route the request to different backend server which can handle the request. This Intelligence cannot be Implemented in Layer 4 Load balancing.

CDN (Content Delivery Network): CDN is a group of geographically distributed servers that hold static content for faster delivery.
The clients look for content in CDN first, then progress to backend services.
CDNs shorten the time required for a server to communicate with a client by reducing the geographical distance between the server and the client.

API Gateway: An API gateway is an API management tool that sits between a client and a collection of backend services. This handles incoming requests and routes them to the relevant services. It talks to the identity provider and service discovery.

API Gateway Capabilities:
Authentication and authorization
Caching
Rate Limiting
Request Validation
Data Transformation and many more

--

--