WittCode💻

Proxy vs Reverse Proxy vs Load Balancer

By

Learn the differences between a proxy, reverse proxy, load balancer, and the common use cases of a proxy, reverse proxy, and load balancer.

Table of Contents 📖

What is a Proxy?

A proxy is a server that acts as an intermediary between a client and the web server holding the desired data. For example, say a web browser makes a request to wittcode.com, a proxy would intercept this request and then forward it to the wittcode.com server. The wittcode.com server would then respond to the proxy and the proxy would forward the response back to the client. Therefore, a proxy server essentially retrieves data from web servers on behalf of a client.

Image

Why use a Proxy?

A common usage of a proxy is privacy. This is because the proxy is making requests to web servers on our behalf. As a result, the web server doesn't know about the original client making the request. However, it should be noted that proxies can do what they want with the request they receive. So it might not be completely private. For example, the proxy server could log the websites that each user visits through it.

Another common usage of a proxy is speed. This is because the proxy can cache data. Therefore, if another user wanted to access a website through the proxy that they or another user accessed previously, instead of requesting that data from the internet, the proxy can return the cached data. Proxies are also commonly used to block certain websites. For example, a company could funnel its employees requests through a proxy that blocks websites they don't want their employees to visit.

What is a Reverse Proxy?

A reverse proxy is what the name suggests, a proxy but in reverse. In a proxy, we defined the intranet as on the client side. In other words, the intranet consisted of the proxy and the clients. In a reverse proxy, the intranet consists of the reverse proxy and one or more server instances. Another way we can look at this is a proxy acts on behalf of clients while a reverse proxy acts on behalf of servers. For example, say wittcode.com consists of a server on the backend, when a client sends a request to wittcode.com the reverse proxy server will intercept the request and then forward it to the backend server. If there are multiple server instances, the reverse proxy will forward the request to a specific server. In both instances, the server will then respond to the reverse proxy and the reverse proxy will forward the response back to the client.

Image

Why use a Reverse Proxy?

A common usage of a reverse proxy is to improve performance of the backend of an application. Reverse proxy servers can cache content, so if a client requests a resource that either they or a different client has requested before, the reverse proxy can send back the cached content without having to pass the request to the application servers. Reverse proxies also protect the identity and hide the infrastructure of application servers as the client doesn't interact directly with the application servers. However, one of the best uses of a reverse proxy is using it as a load balancer.

What is a Load Balancer?

A load balancer is a reverse proxy, but a reverse proxy isn't necessarily a load balancer. A load balancer takes incoming requests from clients and distributes them among a group of servers. For example, say wittcode.com consists of multiple backend servers. When a client makes a request, the load balancer will intercept it, forward it to a selected server, the server will handle the request, respond back to the load balancer, and then the load balancer forwards the response back to the appropriate client.

Image

Why use a Load Balancer?

Load balancers are helpful for sites that receive a lot of traffic/requests. For example, a ton of requests might be too much for a single server to handle. To handle this, multiple servers can be deployed. These servers often host the same content and the load balancer distributes the requests among the servers in a way that optimally uses each server, preventing the servers from overloading and making maximum use of each server's capacity.

Summary

But there we have it! Proxies, reverse proxies, and load balancers are all fairly similar and have a lot of benefits. If this article was helpful please consider donating by using the link at the top of the page, sharing this article, and subscribing to my YouTube channel WittCode.

Proxy vs Reverse Proxy vs Load Balancer