What is NGINX?
Why use NGINX?
NGINX provides various services such as reverse proxy, load balance, and rate limit network services. Reverse proxying is useful if we have multiple web services listening on various ports, and we need a single public endpoint to reroute requests internally. This would allow us to host multiple domain names on port 80 while using a combination of different NodeJs, Go and java to power separate web services behind the scenes.
Nginx can handle the logging, blacklisting, load balancing, and serving static files while the web services focus on what they need to do.
The configuration of Nginx is easier than Apache httpd. Nginx was designed for high concurrency, and it is very fast.
How Does NGINX Work?
Before knowing the process of NGINX, let's take a look at how a web server works. When we make a request to open a webpage, the browser contacts the server if that website. Then the server looks for the requested files for the page and sends it to the browser. This is the only simplest kind of work for a request.
The above example is also considered as a single thread. Traditionally, web servers like Apache create a single thread for every request, but Nginx does not work that way. Nginx performs with an asynchronous, event-driven architecture. It smartly follows events of a process.
Nginx divided its job into the worker process and worker connections. Here, worker connections are used to manage the request made and the response obtained by users on the web server; in the same time, these requests are passed to its parent process which is called worker process.
Let's see an example for Nginx server handling concurrent MP3 and MP4 file requests:-
From the above diagram, we can see that a single worker connection can handle around 1024 connections at a time. It is the best ability of a worker connection. There may be 'n' numbers of the worker process in Nginx based on the type of server we have, and each worker process handles different jobs so that it can handle more numbers of concurrent requests.
Finally, the worker process transfers the requests to the Nginx master process, which directly responds to the unique requests only.
Since worker connection can take care of up to 1024 similar requests, because of that, Nginx can handle thousands of requests without any difficulties. It is also the reason why Nginx became an excellent server for busy websites like e-commerce, search engines, and cloud storage.
Features of NGINX
Some features of Nginx are as follows:
What can NGINX and NGINX Plus Do for You?
Nginx and Nginx plus are the best web servers and application delivery solutions used by high traffic web sites such as Netflix, Dropbox, and Zynga. Busiest websites like Google, Netflix, Twitter, Facebook, etc. rely on Nginx and Nginx Plus to deliver their content securely, reliably, and quickly.
JavaTpoint offers Test Series on eLitmas, Amcat, Company Placement Papers, Programming Languages, SSC, Banking, Civil Services etc.