Skip to main content

Beginners guide to NGINX Part 1 - Introduction

 

Beginners guide to NGINX

Table of content 

  1. Introduction
    • Apache Web Server
    • NGINX
    • Multiplexing and Demultiplexing

Introduction

NGINX is a web server, used to serve web pages over the internet, that also works as a reverse proxy, load balancer and caching and caching device. NGINX is pregerred for its single threaded, event-driven and master-slave architecture.
 
Let is understand the traditional apache web-server architecture.

Apache web server architecture  

 

Apache also known as HTTPD is an open source web server that follows a process driven approach and creates a new thread for each new request. 

The MPMs (Multi-Processing Modules) in Apache, provides a flexible architecture for choosing different connections and different handling algorithms. 

The three main Apache MPMs are: 

1.Process (Pre-fork) MPM

2.Worker MPM

3.Event MPM 

By default, Apache is configured in Pre-fork mode (mpm_prefork). It responds to a set number of processes, each of which can serve a single request at a time.

In other words, Apache creates a new thread every time to handle each connection request.

However, Apache’s basic architecture can lead to heavy resource consumption, thereby, can cause issues with the server (eg- slow speed).

NGINX 


NGINX employs an event-driven architecture and deals with the requests asynchronously.

It was designed to use a non-blocking event-driven connection handling algorithm.

Thus, its process can handle thousands of connection (requests) within one processing thread. It uses the concept of Multiplexing to achieve this. 

NGINX has sliced into three different parts. They are

  • Master:

NGINX follows the master-slave architecture. The Master will allocate the jobs for the workers as per the request from the client. Once the job allocated to the workers, the master will look for the next request from the client that’s it won’t wait for the response from the workers. Once the response comes from workers master will send the response to the client. 

  • Worker: 

Workers are the slaves in the NGINX architecture, will heed to the Master. Each worker can handle more than 1000 request at a time in a single-threaded manner. Once the process gets done, the response will be sent to the master.  

  •  Caching

NGINX cache is used to render the page very fast by getting from cache memory instead of getting from the server. The pages are getting stored in cache memory on the first request for the page.

Multiplexing and Demultiplexing

 

Multiplexing it generally referred to the process and techniques of transmitting multiple analog or digital input signals or data streams over a single channel. 

Demultiplexing(Demuxing) is the rever of the nultiplexing process and it involves reconverting a signal containing multiple analog or digital signal streams back into the original separate and unrelated signals.

Thank you folks.

 

Most viewed

Understanding ASCII / Unicode character encoding format

Computer stores everything in binary format. The process of converting a value into binary is called Encoding and the the process of converting value from binary is called Decoding. value --> binary  ::     Encoding  binary --> value   ::    Decoding for example: A number 12 is stored in its binary format as below.               12 ---> 00001100 but how are the characters are stored? If we want to store a character 'a' what formatting should be used ? It easiest way is to map the characters to number and store the binary format of that number. So, the character 'a' is represented as number 97 is stored as 1100001.  ASCII: In ASCII encoding format, 128 unique characters are identified and mapped with numbers (mostly English). One byte is used to represent all the characters. It uses 7 bits to represent numeric value 0 to 127 (total 128 characters).  The most significant bit is a...