Introduction
Load balancer and reverse proxy are the components which are exposed to the client and abstracts the internal system which extends various benefits including scaling, maintenance, flexibility to change, security etc.
Load Balancer
Load Balancer distributes incoming requests to computing resources. Load balancer can be implemented using hardware or software. Hardware solutions are expensive compared to software solutions.
Benefits
- Distributes the load.
- Prevents requests to unhealthy instances.
- Overcome Single Point of Failure.
- SSL Termination
- Session Persistance.
Distribution Methods
- Random
- Round Robin
- Based on Session/Cookie
- Least loaded instance
- Layer 4 (Transport Layer) - Using source/destination IP, ports in header.
- Layer 7 (Application Layer) - Using header content, message and cookies.
Reverse Proxy
Server acts an interface to internal services. Client requests are forwarded through reverse proxy.
Benefits
- SSL Termination
- Caching staic content
- Compress/Encrypt server response
- Flexibility to update underlying server configurations
Note: Tool like nginx can be used as both load balancer and reverse proxy at layer 7 (Application layer).