Load Balancer vs Reverse Proxy: While both the intermediate components in a typical client server architecture; and are used interchangeably, there are subtle differences between the two.
Load Balancer – takes the incoming client requests and distributes them among a pool of backend servers. Note: they are added when there are multiple backend servers and we would like to distribute the incoming traffic to those servers. Why? For the following reasons:
- Service Availability and hence, reliability – Eliminates single point of failures by monitoring servers health and redirect requests to healthy servers if there is a failure.
- Service Scalability – handling more requests without overloading a single server by distributing requests across multiple backend servers and returning the response back to clients.
- Session Persistence – HTTP is stateless, however, many applications like ecommerce website shopping carts need to store session information to ensure all requests for a particular session are handled by the same server.
Reverse Proxy: This intermediate component is added between a client and a server even where there is only one backend server to take the client request and forward it to the server and then return the response back to the client. Why? Because it provides:
- Scalability: By using reverse proxy, you can add or update the backend infrastructure without impacting any client configurations. This helps while adding newer servers or removing any unhealthy servers. Reverse proxy can have load balancing capability as well, but it’s not necessary.
- More security – By hiding the backend servers, it prevents several malicious attempts on the service by masking the server IP address. Reverse Proxy has several features like IP deny lists and maximum connection requests to mitigate DDoS (distributed denial-of-service) attacks
- Improved latencies – provide compression and decompression features. Compression of request and server responses results in reduced bandwidth consumption which in turn leads to faster transmissions.
- SSL Termination of HTTP and TCP – Provide encryption and decryption of data, thus saving backend servers of these computationally expensive operations.
- Response Caching – Reverse Proxy can store local copies of the data to prevent additional server hops.
Proxy: Opposite of Reverse Proxy, placed before the clients instead of servers before a client request is sent to the internet to mask client IPs and provides additional security in addition to:
- Acts as a filter or a firewall for client machines onyour intranet.
- Provides security from cyber/ phishing attacks.
- Provides encryption/ decryption of requests and masking the IP addresses.
- Performance – provides caching of frequent requests, and compression/ decompression of requests.
Type of load balancers
- Layer 4
- Layer 7