Standing at the forefront of our applications, front ends see the highest concurrency and throughput demands, so designing scalable front-ends are crucial to a performant application that intends to grow. Fortunately, tools exist to help us architect a robust front-end layer. Nginx is one of those tools.
Nginx is a popular piece of software that can play many roles in the architecture and infrastructure of your web application. It enables almost 50% of web servers for the top 1,000 websites around the world (read more here). Should you check out their website you will see claims that it can be a reverse proxy, load balancer, and many other things. To better understand why you might want to use Nginx let’s explore some different roles it can fulfill.
Load balancers are a key player in scaling horizontally. Read more about horizontal scalability in my last blog post here. A load balancer will distribute requests among your servers. It is the service that will first receive your users' request and with the help of different algorithms, it will decide which server in your pool or farm of servers it will send the request to. Load balancers ensure we're making efficient use of all of our horizontal resources.
Load balancers help your users have a smooth experience through thin and thick. No matter how many servers we have and how beefy they are, they will eventually malfunction or need to be temporarily disabled for maintenance. Similarly, as our application grows we will probably want to add more servers to handle more requests. Load balancers are aware of new servers being available, servers no longer behaving correctly, or servers simply being too busy. With this information, they will send requests to the servers that do work, allowing you to take servers in and out without disrupting service. This ability also makes it possible to roll out new updates without any downtime.
A reverse proxy server also intercepts requests from the clients to your servers. Their value comes from their ability to serve as a load balancer, cache content, and provide you with more security. Caching data is another incredible functionality that goes a long way in creating a smoother experience for your users. Data can be cached (stored for later use) in different layers and types of servers. When data is cached in a reverse proxy server, it will be because the data is frequently requested by different clients. We can store frequently requested data to more quickly send a response while at the same time decreasing the load on the server. Lastly, a reverse proxy is also able to provide an extra layer of security as they can limit requests from a particular client that may be trying to intentionally overload your servers with requests.
Thanks for reading! I am open to learning more and answering questions in the comments :)