mirror of
				https://github.com/donnemartin/system-design-primer.git
				synced 2025-11-04 10:12:32 +03:00 
			
		
		
		
	Add Reverse proxy section
This commit is contained in:
		
							
								
								
									
										43
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										43
									
								
								README.md
									
									
									
									
									
								
							@@ -802,3 +802,46 @@ Load balancers can also help with horizontal scaling, improving performance and
 | 
			
		||||
* [Layer 4 load balancing](https://www.nginx.com/resources/glossary/layer-4-load-balancing/)
 | 
			
		||||
* [Layer 7 load balancing](https://www.nginx.com/resources/glossary/layer-7-load-balancing/)
 | 
			
		||||
* [ELB listener config](http://docs.aws.amazon.com/elasticloadbalancing/latest/classic/elb-listener-config.html)
 | 
			
		||||
 | 
			
		||||
## Reverse proxy (web server)
 | 
			
		||||
 | 
			
		||||
<p align="center">
 | 
			
		||||
  <img src="http://i.imgur.com/p7xHS4Z.png">
 | 
			
		||||
  <br/>
 | 
			
		||||
  <i><a href=https://commons.wikimedia.org/wiki/File:Proxy_concept_en.svg>Source: Wikipedia</a></i>
 | 
			
		||||
  <br/>
 | 
			
		||||
</p>
 | 
			
		||||
 | 
			
		||||
A reverse proxy is a web server that centralizes internal services and provides unified interfaces to the public.  Requests from clients are forwarded to a server that can fulfill it before the reverse proxy returns the server's response to the client.
 | 
			
		||||
 | 
			
		||||
Additional benefits include:
 | 
			
		||||
 | 
			
		||||
* **Increased security** - Hide information about backend servers, blacklist IPs, limit number of connections per client
 | 
			
		||||
* **Increased scalability and flexibility** - Clients only see the reverse proxy's IP, allowing you to scale servers or change their configuration
 | 
			
		||||
* **SSL termination** - Decrypt incoming requests and encrypt server responses so backend servers do not have to perform these potentially expensive operations
 | 
			
		||||
    * Removes the need to install [X.509 certificates](https://en.wikipedia.org/wiki/X.509) on each server
 | 
			
		||||
* **Compression** - Compress server responses
 | 
			
		||||
* **Caching** - Return the response for cached requests
 | 
			
		||||
* **Static content** - Serve static content directly
 | 
			
		||||
    * HTML/CSS/JS
 | 
			
		||||
    * Photos
 | 
			
		||||
    * Videos
 | 
			
		||||
    * Etc
 | 
			
		||||
 | 
			
		||||
### Load balancer vs reverse proxy
 | 
			
		||||
 | 
			
		||||
* Deploying a load balancer is useful when you have multiple servers.  Often, load balancers  route traffic to a set of servers serving the same function.
 | 
			
		||||
* Reverse proxies can be useful even with just one web server or application server, opening up the benefits described in the previous section.
 | 
			
		||||
* Solutions such as NGINX and HAProxy can support both layer 7 reverse proxying and load balancing.
 | 
			
		||||
 | 
			
		||||
### Disadvantage(s): reverse proxy
 | 
			
		||||
 | 
			
		||||
* Introducing a reverse proxy results in increased complexity.
 | 
			
		||||
* A single reverse proxy is a single point of failure, configuring multiple reverse proxies (ie a [failover](https://en.wikipedia.org/wiki/Failover)) further increases complexity.
 | 
			
		||||
 | 
			
		||||
### Source(s) and further reading
 | 
			
		||||
 | 
			
		||||
* [Reverse proxy vs load balancer](https://www.nginx.com/resources/glossary/reverse-proxy-vs-load-balancer/)
 | 
			
		||||
* [NGINX architecture](https://www.nginx.com/blog/inside-nginx-how-we-designed-for-performance-scale/)
 | 
			
		||||
* [HAProxy architecture guide](http://www.haproxy.org/download/1.2/doc/architecture.txt)
 | 
			
		||||
* [Wikipedia](https://en.wikipedia.org/wiki/Reverse_proxy)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user