Well, this post is an answer to my endless contemplation on articulating the role of NGINX in this digital era through a blog.
Have you ever wondered, how the browser is serving you all the content with just one click? Have you never had an agog about the backend process and the technicalities behind this? Let's see in this Post.
What is NGINX?
NGINX pronounced as EngineX is a server software that serves the web content to the browser(after retrieving it from the server) and it also acts as a reverse proxy and load balancer. It also accelerates web performance and facilitates scalability and security. In addition to this, it also performs encryption and decryption activity.
NGINX as a Reverse Proxy
A proxy server is an intermediary server that forwards requests from multiple clients to different servers across the Internet. A reverse proxy server is a type of proxy server that typically sits behind the firewall in a private network and directs client requests to the appropriate backend server (Like how Nginx routes the request to the appropriate server with the help of the Route Robbin algorithm).
Load Balancing
Nginx acts as a security sitting in front of the backend servers, forwarding multiple client requests across a group of servers to maximize the efficiency and scalability while ensuring no server is overloaded, which can degrade performance. If a server goes down, the load balancer redirects traffic to the remaining online servers.
Client - Server Communication before NGINX
Here, when we type something( or search in Google, Firefox etc) the Wifi Provider (through IP address) will route our request to the server and from the server it will route back the response to our screen through the IP address. This is the Usual Process and this is fine for a small website that has less user traffic.
But for large-scale websites like Amazon and Flipkart, this usual method will not be feasible as these websites are flooded with thousands of requests per second and there arises a need for multiple servers.
Because when the traffic is more and the server capacity is less, the traffic that is coming inside the server will make the server reach its bottleneck, which will reduce the latency of the servers. Here Comes NGINX.
PROBLEM NGINX SOLVES
When the traffic that is coming to the website increases, there is a default need for the organization to increase the number of servers for a smooth customer experience.(Best ways to build multiple servers is through Dockers, because through Dockers we can build multiple server containers that are isolated)
Increasing the number of servers( For Example Three Servers ) is also a problem as our request will go to all three servers which will increase the time taken to receive the response. So here comes Nginx as a Solution for Time Latency.
Here in some cases, the user has to decide, out of three servers, to which server I should send my request. But here in the case of Nginx, we no need to worry about which server I should make the request.
Here user sends their request only to Nginx and Nginx is responsible to forward the request to the available servers and Nginx will forward back the response to the client which it got back from the server.
Here the Nginx will choose which server to forward the request and this is done using an algorithm( like Route Robbin Algorithm) in Nginx
Here as we are having multiple servers it is difficult to encrypt at every server, so here as we send the request, Nginx Will encrypt and send it to the server and after getting the response from the server, Nginx will decrypt and it will send back to the user. Here Nginx itself will perform the encryption and decryption action, to take load off of your servers, thereby boosting their performance.
Simply, NGINX is nothing but an intermediary server, that facilitates the client-server communication of a web app with multiple servers ensuring efficiency, security, speed and scalability.