I was recently helping my friend with some preparation for a system design interview and as we discussed solutions, the terms Proxy server and reverse proxy came up in our discussions.
I really struggled to give a simple explanation of the terms during our discussion. I just knew what one did. I did not even know that load balancers were generally reverse proxies. This is where knowledge of a natural language could be helpful. So I thought I would try and compile a simple description of both here and go look at the definition of Proxy from the dictionary.
Meaning of proxy in English: UK
Definition: authority given to a person to act for someone else, such as by voting for them in an election, or the person who this authority is given to.
A proxy server , just as the definition of proxy earlier, is a server that acts as the middleman between a client and a server on the internet that makes requests to web resources for a client, thereby hiding the identity of a client.
Why is it useful?
You or your organisation could be using a Proxy Server for many reasons.
- Anonymity - as all requests from the client first go to the proxy and the proxy then makes that request to the actual server to fetch content it does not give away who made the original request
- Restrictions - Proxies can restrict access to certain parts of the internet. Maybe your country or organisation forces the use of a proxy server for all outgoing traffic to restrict you from watching porn or spending too much time on reddit or youtube or what not. This information could also be logged and you could get in real trouble.
- Speed - caching content from outside in the proxy server will make subsequent requests to the same page much faster! I mean, caching any static data is always going to improve the performance of your application anyway.
Unlike a VPN, however, a proxy server does not generally encrypt your browsing data. VPN gives you a dedicated encrypted tunnel between the client and the server.
Where a proxy server anonymises the client, the reverse proxy anonymises the server. The reverse proxy makes it impossible for a client to tell which server is serving its request.
Why is it useful?
- Load balancing - scale your application on servers behind the reverse proxy and your clients won’t have to know which server to connect to because the load balancing reverse proxy server would deal with routing requests to the right server based on some fancy algorithm of your choice.
- Caching - static content could be cached here to improve performance of your clients.
- Logging - All incoming requests, params, body and responses could be logged at the reverse proxy
- Deployment - selectively deploy to a certain server or servers and not impact all the clients at once. This can be a really easy way to ensure zero downtime deployments, although these days you’ll get better tools from your cloud provider to achieve this.