Usually a forward proxy
Think of it like a friend (middle layer, proxy) hides and protects the original persons ID, and does something on your behalf
Forward Proxy → Sitting inbetween client and server or set of clients and server (or set of servers), communicates on behalf of the client to the server
In summary, a forward proxy server serves as an intermediary in network communication
Reverse Proxy → Sitting between server and clients and acts on behalf of servers, typically used for logging, load balancing, or caching.
Reverse and Forward Proxy Diagram
Works as a type of reverse proxy, you redirect cleints requests / Traffic based on some logic the server admin has determined in the load balancer.
After you throw in a load balancer, you can then horizontally scale those servers as needed.
How exactly do we distribute that traffic evenly though?
Many Algorithms to do this! (Round Robbin, Weighted Round Robin, User Location, Least Number of COnnections, Layer 4 and Layer 7 Load Balancing)
Round Robbin → essentially just send a request sequentially to each server as they come, and keep going until. I.e. suppose you have 3 servers. Req1 → Server 1, Req2 → Server 2, Req3 → Server3, and then Req4 → Server 1, …, and so on.
Weighted Round Robbin → Each server gets requests based on how much they’ve been configured to handle (i.e in the diagram below, 50% of the requests should go to server 1, and 25% to server 2 & 3)
Least Number of Connections → Send requests to server that is currently dealing with the LEAST number of requests. ****
User Location → If users are geographically located closer to a specific server, we could route them to the server that is closest to them
Under this strategy, we want to ensure that users receive data from the nearest server, minimizing the distance that data needs to travel. This approach helps reduce latency and provides a faster and smoother user experience.
If our servers A, B, and C located in Asia, Europe, and North America, respectively, the load balancer uses the user's IP address to determine their location. Based on this information, the load balancer routes the user's request to the corresponding server that is geographically closest to them. This helps optimize response times and reduces latency by delivering the content from the server in close proximity to the user.
Layer 4 and Layer 7 → Load balancers at different levels of network layers
Recall the OSI model, which provides a standard for different computers to communicate w/ each other (universal language for computer networking, by splitting up the communication into seven layers)
Here, Layer 4 load balancer technique works corresponds to the Transport layer, which is responsible for end-to-end communication using TCP, UDP, etc. Layer 4 load balancers are designed to route traffic based on Layer 4 data, such as IP address and TCP port, rather than the contents of the requests. This approach makes Layer 4 load balancing fast and straightforward.
Layer 7 (Application) Load Balancers → We can see the data itself, we can intelligently route user requests based on what type of request it is.
For example, having a server deal with tweets, another with user authentication, another with browsing new content, etc.
The downfall of Layer7 is that it has MULTIPLE connections. We have TCP connections from Client → Load Balancer and then another TCP connection from Load Balancers → Servers; which is required for being able to see / decrypt each request
Whereas for the Layer 4 just forwards the IP to one of the server, and returns it back
Layer 7 → Slower, but much more flexible
Layer 4 → Faster, but much more restricted
What happens if you only have 1 load balancer? What if it goes down itself?