Chapter 8

Load Balancers, Proxy and Reverse Proxy Servers

By Nikhila Sattala
October 12, 2021
Introduction goes here
Load Balancer

Load balancing is a crucial technique for managing network traffic and optimizing the performance of applications. It involves distributing incoming traffic evenly across a group of servers that support an application. This is essential for ensuring that the application can handle many users at once and deliver content like text, videos, images, and data quickly and reliably.

Think of a load balancer as a traffic cop for the internet. It stands between users and a group of servers, making sure that each server gets a fair share of the incoming requests. This not only improves the overall performance but also ensures that the application remains accessible even when there's a surge in traffic or if some servers encounter issues.

In a world where fast and dependable digital services are essential, load balancers are like the unsung heroes that help keep everything running smoothly. They ensure that applications can handle a large number of users and deliver content without hiccups, making them a vital part of modern digital systems.

How does Load Balancer Work?

In simple terms, a load balancer manages the flow of internet traffic to multiple servers, ensuring that each server does its fair share of work, and your website stays fast, responsive, and reliable even when many people are using it.

Incoming Traffic: When users try to access your website, their requests go to the load balancer first.

Distribution: The load balancer's job is to distribute these requests evenly among a group of servers. It makes sure no single server is overloaded.

Health Checks: Load balancers regularly check the health of the servers. If one server is not working correctly (maybe it's slow or has a problem), the load balancer can stop sending traffic to it temporarily.

Session Persistence: Sometimes, it's essential to keep a user connected to the same server (for example, when they're logged into an account). Load balancers can use techniques like session persistence to ensure this.

Scalability: If your website becomes even more popular, you can add more servers to handle the increased traffic. The load balancer will automatically start sending some requests to these new servers.

Failover: In case a server completely fails, the load balancer redirects traffic to the healthy servers, ensuring your website remains accessible.

Proxy server
A forward proxy, commonly known as a "proxy server," is a server positioned between one or more client computers and the internet. It acts as an intermediary, facilitating communication between the clients and internet resources.

When a client sends a request, the forward proxy intercepts it and forwards it to the desired internet resource. Subsequently, the forward proxy receives the response from the internet resource and relays it back to the client machine.

Forward proxies are primarily employed for the following purposes:
  • Enhancing Client Anonymity
    Forward proxies provide a layer of anonymity for client machines by masking their IP addresses. Internet resources see requests originating from the proxy server's IP, safeguarding the privacy of the client.
  • Caching
    Forward proxies can store copies of frequently accessed web resources locally. When a client requests a cached resource, the proxy server delivers it, reducing load times and conserving bandwidth.
  • Traffic Control
    Administrators can use forward proxies to control and filter internet traffic, enforcing policies that limit or restrict access to specific websites or content categories.
  • Logging
    Forward proxies maintain logs of incoming and outgoing traffic, allowing administrators to monitor network activity, diagnose issues, and track user behavior.
  • Request/Response Transformation
    In some cases, forward proxies can modify the content of requests or responses, enabling tasks such as content filtering or translation.
  • Encryption
    Forward proxies can facilitate SSL/TLS encryption, ensuring secure communication between clients and internet resources, which is essential for protecting sensitive data.
Reverse Proxy Server
A reverse proxy is a server strategically positioned in front of one or more web servers, acting as an intermediary between these web servers and the broader Internet. When a client initiates a request, the reverse proxy intercepts it and forwards it to the appropriate web server. Following this, the reverse proxy awaits the response from the chosen server and subsequently delivers it back to the client.

Reverse proxies are chiefly employed for the following purposes:
  • Enhancing Server Anonymity
    Reverse proxies protect the identity and location of web servers by masking their IP addresses. This anonymity helps secure the backend infrastructure from direct exposure to the Internet.
  • Caching
    Reverse proxies can store cached copies of frequently requested content, reducing the load on web servers and improving response times for clients.
  • Load Balancing
    They distribute incoming client requests across multiple backend servers, ensuring efficient resource utilization and high availability.
  • DDoS Protection
    Reverse proxies can act as a shield against Distributed Denial of Service (DDoS) attacks by absorbing and mitigating malicious traffic before it reaches web servers.
  • Canary Experimentation
    Organizations use reverse proxies to route a portion of traffic to specific backend servers for testing new features or changes before deploying them universally.
  • URL/Content Rewriting
    Reverse proxies can rewrite URLs or manipulate content in real-time, enabling tasks such as content transformation or URL redirection.
Nginx, HAProxy, Citrix ADC are a few examples of reverse proxy servers.