What is difference between Apache and Nginx

What is difference between Apache and Nginx
What is difference between Apache and Nginx


Same Difference between Apache and Nginx

Apache works in a multi process/multi threaded architecture, but nginx is an event driven single threaded architecture.
Nginx doesn’t create a new process for a new request. Apache creates a new process for each request.
In Nginx, memory consumption is very low for serving static pages. But, Apache’s nature of creating new process for each request increases the memory consumption.
Apache, It cannot process multiple requests concurrently with heavy web traffic.
Nginx, It can process multiple client requests concurrently and efficiently with limited hardware resources.
Apache Modules (MPM) Multi Processing Modules.
Prefork MPM :- Prefork MPM launches multiple child processes. Each child process handle one connection at a time, So new request do not need to wait for new process to start.

###############################################################################
#prefork MPM
#StartServers: number of server processes to start
#MinSpareServers: minimum number of server processes which are kept spare
#MaxSpareServers: maximum number of server processes which are kept spare
#ServerLimit: maximum value for MaxClients for the lifetime of the server
#MaxClients: maximum number of server processes allowed to start
#MaxRequestsPerChild: maximum number of requests a server process serves
#########################################################################

StartServers       10
MinSpareServers    5
MaxSpareServers   20
ServerLimit      250
MaxClients       250
MaxRequestsPerChild  4000

#########################################################################


Prefork - For simplicities sake lets say that each process requires 1% cpu and 10mb of RAM.
Prefork  -------- > Request --- 1% CPU - 15 MB RAMPrefork  -------- > Request --- 1% CPU - 15 MB RAMPrefork  -------- > Request --- 1% CPU - 15 MB RAMPrefork  -------- > Request --- 1% CPU - 15 MB RAM

So in the instance above we have 4 processes which use up 4% of your CPU and 60MB of RAM.

Worker MPM :- Worker MPM generates multiple child processes similar to prefork. Each child process runs many threads. Each thread handles one connection at a time. In sort Worker MPM implements a hybrid multi-process multi-threaded server. Worker MPM uses low memory in comparison to Prefork MPM.
##############################################################################
#worker MPM
#StartServers: initial number of server processes to start
#MaxClients: maximum number of simultaneous client connections
#MinSpareThreads: minimum number of worker threads which are kept spare
#MaxSpareThreads: maximum number of worker threads which are kept spare
#ThreadsPerChild: constant number of worker threads in each server process
#MaxRequestsPerChild: maximum number of requests a server process serves
#############################################################
#######
<IfModule worker.c>
StartServers 4
MaxClients 350
MinSpareThreads 20
MaxSpareThreads 65
ThreadsPerChild 20
MaxRequestsPerChild 0
</IfModule>
##############################################################
#
Worker MPM  ----------> Request
Worker MPM  ----------> Request All these request use up 2% CPU and 32 MB of ram.
Worker MPM  ----------> Request
Worker MPM  ----------> Request

Event MPM :-
This MPM allows more requests to be served simultaneously by passing off some processing work to supporting threads. Using this MPM Apache tries to fix the ‘keep alive problem’ faced by other MPM. When a client completes the first request then the client can keep the connection open, and send further requests using the same socket, which reduces connection overload.

What is difference between Apache and Nginx What is difference between Apache and Nginx Reviewed by Unknown on June 06, 2018 Rating: 5

1 comment:

Scribe

http://feeds.feedburner.com/LinuxAndAws
Powered by Blogger.
X

Get Updates On

Linux Tutorial

AWS Tutorial

Devops Tutorial

We are going to send you our resources for free. To collect your copy at first, join our mailing list. So don't miss any updates, stay connected!