Proxies in System Design
What are Proxies?
In system design, a proxy is an intermediary server or software component that sits between a client and a server. The proxy server acts as a gateway or an intermediary between the client and the server, handling requests and responses between them.
Let's try and explain these simple terms:-
Imagine you are playing a game with your friends and you need a special toy from your friend to continue playing. Instead of going to your friend's house every time you need the toy, you ask your big brother or sister to get the toy for you. Your big brother or sister becomes a proxy, going to your friend's house to get the toy and bringing it back to you so you can keep playing.
In system design, a proxy is like a big brother or sister. It helps your computer or phone talk to other computers or websites by getting information and data for you, so you don't have to go get it yourself every time. The proxy can also help protect you by making sure that the information and data you get are safe and not harmful.
Types of Proxy
Forward Proxy
A forward proxy is a proxy server that sits between a client and the server. When a client requests to access a resource on the server, the request is first intercepted by the forward proxy server. The proxy server then sends the request to the server on behalf of the client, and when the response is received from the server, it is then sent back to the client by the proxy server.
Forward proxy sits on the client side.
An example of a forward proxy can be - Content Filtering: A forward proxy server can be used to filter web traffic and block access to specific websites or types of content. This is often used in schools or businesses to enforce acceptable use policies and prevent access to inappropriate or unauthorized websites.
In summary, a forward proxy is a server that acts as an intermediary between a client and the server, forwarding requests and responses between them.
Reverse Proxy
In system design, a reverse proxy is a server that sits between a client and one or more servers. Unlike a forward proxy, which sits between a client and the server, a reverse proxy sits between a client and one or more servers, forwarding requests and responses between them.
When a client requests to access a resource, the request is first intercepted by the reverse proxy server. The proxy server then forwards the request to one of the servers behind it that can fulfil the request. When the response is received from the server, it is then sent back to the client by the proxy server.
The reverse proxy sits on the server side.
An example of a reverse proxy can be - Increasing Scalability: Reverse proxies can increase the scalability of a web app by forwarding requests to load balancers which in turn send the request to a server that can handle the request.
In summary, a reverse proxy is a server that acts as an intermediary between a client and one or more servers, forwarding requests and responses between them.
Pros & Cons of Proxies
Pros
One of the main advantages of using proxies is that they can improve the performance and security of web applications. Proxies can cache frequently accessed resources, filter traffic, and hide the identity and location of the client or server, among other things. This can help to reduce bandwidth usage, speed up access to resources, and enhance security by adding a layer of protection against malicious attacks.
Cons
One of the main disadvantages of using proxies is that they can introduce additional latency and complexity to the system. Since each request and response must pass through the proxy server, this can add some overhead and increase the time it takes to access resources. Additionally, setting up and configuring proxies can be complex and require expertise, which can make it more difficult to manage and maintain the system.
Reference
I am learning system design basics from SudoCODE.
Connect with me
If this blog helped you in some way, drop me a 'Hi' on Twitter and connect with me.