[Web Architecture] Reverse Proxy vs Load Balancing

According to nginx.com, the definition of Reverse Proxy and Load Balancer are:

  • reverse proxy accepts a request from a client, forwards it to a server that can fulfill it, and returns the server’s response to the client.
  • load balancer distributes incoming client requests among a group of servers, in each case returning the response from the selected server to the appropriate client
At this point, it almost seems as if they are the same thing. Let's dive deeper to see the difference.

Load Balancing

Sometimes, the volume of requests generated from your website may be too much for one server to handle. In that case, you will use multiple servers. But even then, you will need something to distribute the requests to each server; evenly. This 'something' is the load balancerThey basically solve network traffic problems.

Session Persistence

A cool thing that I also read about is session persistence. Will need more researching for this...

Reverse Proxy

When I was working on a Web Scraping project, I read that to avoid websites from banning your IP due to requesting inhuman amounts of requests, one had to use several proxies so it thinks several different IPs (assuming 1 IP per computer) was accessing.

Proxy, in a way, masks your IP. They do this by having another IP. They will take in your request, and send it to the website on your behalf. When the website responds, they forward the request back to you. That's how they 'mask' your IP. So even if the website tries to ban your IP, they are actually banning the proxy's IP.

In the same way, websites can have proxies of their own. These are called "Reverse Proxy". The reason for this is so users cannot directly reach the server's IP.

Security Reasons:
  • No information about your backend servers are exposed outside your internal network, making it harder for malicious clients to access and exploit vulnerabilities.
Performance Reasons:
  • Compression - compressing server responses before returning them to the client (eg. using gzip) reduces amount of bandwidth required - speeding up network.
  • SSL - while encryption of traffic between clients and servers protects it across the public network, dycrption and encryption can be computationally costly. By doing this instead of the server, reverse proxy frees up resources for the server that would have been used for do encryption and decryption.
  • Caching - When the client makes the same request, the reverse proxy can store the copy of the response ahead of time and provide a response to the client without having to get to the server. This decreases response time to the client and reduces load on the backend server. 

Sources:

https://www.nginx.com/resources/glossary/reverse-proxy-vs-load-balancer/

Comments

Popular posts from this blog

[Redis] Redis Cluster vs Redis Sentinel

[Unit Testing] Test Doubles (Stubs, Mocks....etc)

[Node.js] Pending HTTP requests lead to unresponsive nodeJS