Understanding of Web Server and Nginx
Hi friends, I will explain my understanding of Nginx and how it works.
We should know the Webserver before we learn Nginx.
What is Webserver?
The computer which is basically serving you with the web page is nothing but a webserver.
Web servers are computers that deliver the requested web pages. Every web server has an IP address and a Domain name.
The term refers webserver can refer to hardware or software, or both of them working together.
- On the Hardware side, a web server is a computer that stores web server software and components files of websites (For example HTML document, Javascript, CSS files). A web server connects to the internet and supports physical data interchange with other devices connected to the web.
- On the Software side, a web server includes several parts that control how web users access hosted files. At a minimum, this is an HTTP server. An HTTP server is a software that understands URL (web addresses) and protocol (the protocol your browser uses to view webpages). An HTTP server can be accessed through the domain names of the websites it stores, and it delivers the content of these hosted websites to the end user’s device.
At the most basic level, whenever a browser needs a file that is hosted on a web server, the browser requested the file via HTTP.
When the request reaches the correct (hardware) web server, the (software) HTTP server accepts the request, finds the requested document, and sends it back to the browser, also through HTTP.
If the server does not find the requested document, it returns a 404 response instead.
What are the various Web server software:
- Xampp
- Apache
- Nginx
- Tornado
- Caddy
- Microsoft IIS
In this article, I will talk about only Nginx.
What is Nginx
Nginx is open-source software. Nginx is one of the most popular web servers in the world and is responsible for hosting some of the largest and highest-traffic sites on the internet.
Nginx is for reverse proxying, caching and load balancing. It also provides HTTP server capabilities. And mainly designed for maximum performance and stability. Apart from that it also provides Functions with a proxy server for mail(IMAP, POP3 and SMTP). It uses Non-threaded and event-driven architecture.
Nginx in simple words is a webserver. it makes sure your web page load time is reduced.
Nginx Architecture:
Nginx mainly uses Master-Slave architecture. The Master-Slave architecture by supporting event-driven, asynchronous and non-blocking models.
The above one is the Nginx architecture diagram.
According to Nginx architecture basically a single master and many worker processors. Also, there are the special purpose of processers like proxy cache, Cache loader, the Cache manager.
Worker:
The role of the worker is to accept new requests from the shared listen socket. Each worker can process thousands of requests.
Master:
The master process is responsible for reading and validating configuration. Master is responsible for creating and binding the processing sockets. It is also responsible for starting, terminating and maintaining the configured number of processes.
Cache Loader/Cache Manager:
Cache Loader is mainly responsible for checking the on-disk caching item and populating the engine memory with cache meta data. Cache Loader prepares Nginx instances to work with the files already stored on the disk.
Cache Manager is mainly responsible for Cache expiration and validation.
This is all about the architecture of Nginx.
Why should we use Nginx?
- Ease of installation and maintenance
- Improve performance
- Offers scalability
- Reduces the wait time for users
- Load balancing
- On the fly upgrades.
In the upcoming blog, I will explain about Nginx configuration setting.
Thank you for reading. Have a nice day!