System Design Chapter 2 - Proxies
Fundamentals of system design Chapter 2: Proxies
The components of system design
In the previous article we described system design as a major phase in software development. It’s a phase where we describe the elements of a system like architecture, components, modules, interfaces and data based on the system requirements. We looked at the key characteristics of a system. These are things we can trade off: Scalabiliy, Availability, Reliability and Efficiency.In this Article we are going to look at the actual components that makes a system.
Proxies
A proxy server is a piece of hardware or software that acts on behalf of a client or server. There are two types of proxy servers:
a) Forward Proxy Server
A forward proxy server sit on the client side forwarding web requests on behalf of the client. When the clients request a web content, it goes to the proxy first, then the proxy forwards the request to the web server on behalf of the client using it’s IP address. The web server sends the response back to the proxy which forwards the response to the client. The web client is anonymous to the web server in this scenario. An example of a forward proxy is Virtual Private Network(VPN) which hides the Identity of the client.
Benefits of forward proxy server
i. User IP Address is hidden - Enables a user to hide identity therefore guarding privacy.
ii) Easy access of Geo-Blocked/Restricted Content - Some online content are hidden behind geo-restictions mostly because of copyright restrictions. This can be by passed by using a proxy server.
iii. Caching - Forward Proxy server may cache requested data and store them for later. This may reduce page load time significantly to the user.
iv. Improved Security - The Proxy filters and blocks known websites that are malicious to the user.
b) Reversed Proxy Server
On the other hand, a reverse proxy sits in front of one or more servers, intercepting the requests made by the clients. The proxy will then forward the request to the destination server and receives responses. The clients thinks it is directly communicating with the destination server. The proxy in this case resides on the server side and makes sure that no client interact with the origin server directly.
Benefits of reverse proxy server
i. Load Balancing - Reverse proxies can be used as a load balancer to distribute incoming web traffic to multiple web servers.
ii. Caching - Reverse Proxy server may cache data which reduce response time to the user, improving the performance of a system.
iii. Improved Security - Proxy servers offers protection from DDos attacks. A DDos attack is used to exponentially increase requests to the servers in order to overwhelm it and bring the services down. An example is the attack of GitHub which was bombarded by requests 126.9 million request per second. Within 10 minutes, GitHub sounded an alarm and routed the traffic to it’s DDos mitigation service which sorted and blocked the malicious traffic. Proxies can be used to protect the servers from DDos by detecting whether a spike in traffic is legitimate or not, offering a traffic scrubbing effect.
iv. SSL termination - The proxy can handle any incoming HTTPS connections, decrypting the requests and passing the unencrypted requests on to the web servers. This eliminates the need to install SSL certificates in different back end web servers by providing a single point if configuration. It also takes the processing load of encryption and decryption away from the web servers.
v. Logging and Auditing - Proxies makes an excellent point of logging and auditing because all the HTTP requests are routed by the proxy.
Disadvantages of reverse proxy server
i. Increased Complexity - Adding proxies to the architecture increases system complexity.
ii. Single Point of Failure - A single proxy can introduce a point of failure and the addition of multiple proxies will complicate the system further.
Final
Proxies is a key component in improving the performance of a system. A reverse proxy offloads most of your infrastructure concerns of a large traffic distributed application. A good example of reverse proxy is Nginx. In my next article we are going to look at load balancers and how they related to proxies. Happy Coding!
Thank You!
I’d love to keep in touch! Feel free to follow me on Twitter at @codewithfed. If you enjoyed this article please consider sponsoring me for more. Your feedback is welcome anytime. Thanks again!
Comments powered by Disqus.