Facts about NginX
Posted By Oodles Admin | 12-Jun-2015
The increased use of internet, reported a well familiar problem “C10K: enable each web server to be capable of processing 10,000 clients at the same time”. Frequent issues were raised when web server tried to serve more number of requests. The number of request were rising at a very high pace. In order to serve all the requests at comparatively less time, there was an immediate need to develop a better Network I/O and thread management technology. Therefore NginX was emerged to serve “C10K problem”.
NginX was taking over the very well-known Apache which was always at the forefront of web revival. Though both Apache and NginX are free, open-source, cross-platform web servers, still NGINX is growing at faster pace. It is all due to the added features in NginX: Great performance and efficiency over the well-known Apache.
NGINX is a not only a web server, but also a load balancing, HTTP cache. It is an open source proxy server for various protocols. It is lightweight, stable, fast and easy by nature. It is best known tool, if you are attempting to scale up the websites.
It is much efficient for serving static content, having low memory and recommended for VPS. Nginx scales in all directions: from the smallest VPS all the way up to clusters of server. It has been observed that NginX is being used by many websites with massive high traffic
Features of NginX
Static file serving
How NginX works :
NginX has one master process and several worker processes. The main purpose of the master process is to read and evaluate configuration, and maintain worker processes. Worker processes do actual processing of requests. NginX employs event-based model and OS-dependent mechanisms to efficiently distribute requests among worker processes. The number of worker processes is defined in the configuration file and may be fixed for a given configuration or automatically adjusted to the number of available CPU cores.
EDA- Event Driven Architecture
In-order to achieve better performance, density and economical use of server resources while enabling dynamic growth of a website, NginX adopted EDA structure which uses asynchronous Input-Output which tends to increase scalability. NginX doesn’t rely on threads to handle request. EDA is capable of handling more number of connections as compared to Apache which follows conventional structure (one thread for one connection). In Apache, the number of clients and threads are same.
In EDA structure, CPU can be efficiently used with the use of minimum (might be zero thread) number of threads. This architecture uses small, but more importantly, predictable amounts of memory under load.
The formation of NginX code was a result of modular, non blocking, single threaded, asynchronous and event driven architecture.
Formation of NginX code:
Nginx "worker" processes can go through enormous stacks of requests without waiting on each other and without synchronizing; Apache, by contrast, approaches large numbers of requests by spinning off more processes to handle them, typically consuming a lot of RAM.
Event Driven - it is marked by the initiation or completion of a process. Resource can be used by other process until process initiated event is triggered and the resource can be allocated and released dynamically.
By Asynchronous it means that the threads can be executed concurrently without blocking each other. It enhances the sharing of resources without being dedicated and blocked.
By Single threaded it means that, multiple clients can be handled by a single worker process as the resources are not blocked.