Understanding Proxy, Forward Proxy, and Reverse Proxy

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
so proxy is a machine or a set of machine that sits between two systems now the two systems can be a user and a backend system or two backend systems or anything so proxy is just a machine that is sitting in between something in most cases proxy is there to abstract out some complexities or untrusted environment or something so with a very common intention of abstracting out proxy installed now here let's talk about the first kind of proxy which is forward proxy now forward proxy is basically what we all have experienced in our colleges and at our workplaces it basically abstracts out the clients the users Us by acting as a middleman so here it protects the identity of the client and whenever client makes a call the call goes via this proxy to the internet or to some service or to some server this is a forward proxy where we are where it is responsibility of the proxy to forward the request get the response and it is abstracting out the clients it hides the identity of the client now why do we need it security is one of the most important reasons which is where the because it is protecting the client's identity the external systems let's say the internet right or some other service or some other tools they see the IP address only of the proxy they don't know the IP address of this clant it protects the identity right so external site typically sees the IP address of this machine I'll give you a very interesting uh example and a story from my life uh during my masters I was uh part of a hackathon in which I built a search engine on top of linkedin's data so we were scraping LinkedIn data at that time to get the profile information of a lot of users now while we were doing it LinkedIn had employed rate limiting I'm talking 20 14 they had rate limiting employed so when we made a call to LinkedIn repetitively over like using a script after some time rate limiter kicked in and they blocked our IP address the thing is although only I was the one who was making the call the LinkedIn access of the entire College went off because our entire College was behind a proxy for LinkedIn the IP address was of proxy's IP address so it blocked the proxy IP and no matter who was trying to access it it was blocked and it's very common that organizations like educational institutes and corporate setups that typically have a proxy which helps you with protecting the client's identity second reason is about policies like your organizations your education organizations would want to restrict the access to certain types of websites for example torret was banned in our college right in that case because all the request is going through this single machine a lot of policies can can be applied over here for example even in India certain websites are blocked for example Tik Tok is blocked in India so the nation's firewall through which or the IP addresses or the sorry the isps firewall through which the request are going those rules are configured that any request going to Tik tok.com needs to be blocked right that is an example of forward proxy right now certain organizations like for example my website arit bah. me was blogged in Walmart they had to submit a request that hey we want to access this website the it admin used to see what this website is is this good then used to wh list it this this indeed happened with me right third reason because everything is going through this common proxy you can see that you can keep your frequently access content on that I'll give you one other practical example at my at my college the Java docs I'm talking 2008 9 10 11 and 12 so during these years what used to happen was we used to code in Java and the Java is what we had to refer to on whatever whatever we wanted to do with it right so Java docs were cast on the college proxy so that even if the internet is off we would still be able to access Java dos and Java dos website used to load very quickly they used to cat content on the proxy site so the second type of proxy is called reverse proxy which abstracts out the complexities of the downstream systems so here you so the second type of proxy is called reverse proxy that abstracts out the complex cities of the down spring systems so users will connect to a reverse proxy and it is responsibility of the reverse proxy to Route the request to the corresponding node now one very common example of reverse proxy is load balancer so you connect to the load balancer and load balancer depending on the load balancing algorithm it choose to forward the request to one of the servers so here we abstracted out the complexities of how many servers we have what all they do and abstracted that logic out in the reverse proxy right so which is where load balancing is one of the most common reasons why we had reverse proxy another one being routing which is like an API Gateway where your request can come for one of the services let's say if my request start with SL o send it to authentication Service if it start with Slash payments send it to payment service so in Reverse proxy you could also configure your routing logic but helps you route the request to the corresponding set of machines right third is caching because everything is going through the reverse proxy I can cash some of the static responses allowing me to not fire the request to origin server and get the response so for example if let's say one of the blog is very popular I can cat the content of the blog on the load balancer itself so next time the request for that blog comes in I can directly respond back to the users without having a need to go to the API server and get the response it helps me save the bandwidth of my API server and the CPU and the memory of it right routing uh load balancing routing very critical feature caching again very important the fourth one is abstraction so here the best part is that because we are hiding we are abstracting out the elasticity of the infrastructure that we don't know if there are five servers or 10 servers or 15 servers behind this for us reverse proxy becomes a single point of entry I would always make a call to the load balancers domain name and in turn it will make call to whichever server it wants to so it abstracts out that complexities for me making this infrastructure elastic that I can add 10 more servers or reduce five servers I don't care because my user remains unaffected for this so it abstracts out the complexities of the downstream systems while the forward proxy that we discussed it abstracted out the clients from the downstream systems right so look at the box where we placed it in the first one the box is on the clients we are abstracting out the clients so for the other side it's only single entity while the reverse proxy is complete opposite of that where we are abstracting out the complexities and the abing out the complexities of the downstream systems one very cool example very practical example of that is load balancers straightforward API gateways which basically routes the request to the corresponding microservice and database proxies right so load balancers engine x h proxy great tools uh to explore acting as a load balancer for AP Gateway Kong Gateway is a great example let's Sprint sometime talking about DB proxies so proxy SQL is a great uh great uh tool that acts as a DB proxy very similar to load balancer but slightly more advanced so what proxy SQL or what DB proxy does is it accepts the request like a normal SQL query from the client it abstracts out the complexities of the database that in behind the scenes your database can be sharded partitioned across multiple servers we don't care the logic is configured on the DB proxy side right the request goes to proxy SQL proxy followers the request to the corresponding machine again proxy SQL is a concrete example every database has its own sort of database proxy implementation right now what is the use of proxy what is the use of database proxies is it can catch responses like a common SQL query can be cat. proxy SQL so that I don't have to like the proxy SQL need not forward the request to the database for subsequent request only the first one can go while other can be served from this reduces the load on the database second is connection pooling that it accepts a lot of connections from the client but it can make limited connections with the database leveraging and utilizing the database connections to its best ability and third it abstracts out the database topology that we don't know how the data is moved how or who owns Which data and uh the entire topology like how many servers are there that is all abstract out if tomorrow we make from three servers to five servers our user does not need to know they have a single point of contact to reach out to to get the queries answer this is database proxy they're very very very common and very prevalent in system design and most cases Real World Systems so I have been personally using a few out there but this is something that um is very essential reverse proxies they are very prevalent across lot of systems be it for apis or databases I would highly highly highly recommend you to explore it when you find time but yeah that is all what I wanted to cover today I hope you found it interesting hope you found it amazing that's it for this one I'll see you in the next one thanks ATT [Music]
Info
Channel: Arpit Bhayani
Views: 25,169
Rating: undefined out of 5
Keywords: Arpit Bhayani, Computer Science, Software Engineering, System Design, Interview Preparation, Handling Scale, Asli Engineering, Architecture, Real-world System Design, Forward Proxy, Reverser Proxy, System Design Interview, Load Balancer, API Gateway, Database Proxy, Proxy SQL, Why we need Proxy server, Proxy explained
Id: HrG0MHkSsCA
Channel Id: undefined
Length: 9min 41sec (581 seconds)
Published: Fri Mar 29 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.