Menu

Tuesday, 22 May 2018

Apache HTTP Server

What is Web Server ?
A web server is a system or software that delivers content or services to end users over the internet. A web server consists of a physical server, server operating system (OS) and software used to facilitate HTTP communication. 

 Types of Web Servers :-

  • Apache (provided by Apache)
  • IIS (provided by Microsoft)
  • nginx (provided by NGINX)
  • lighttpd

Apache HTTP Server 

Apache web server is a software application , which is most widely  used as a web server application in the world. Since it was officially released in 1995. In 2009,it became the first web server software to serve more than 100 million websites.  Approx 45 % of active sites are running on Apache web server application.Many organizations rely on Apache, including PayPal, Cisco, Apple, and, of course, the Apache Software Foundation.

It is a modular, process-based web server application that creates a new thread with each simultaneous connection.
It supports a number of features; many of them are compiled as separate modules and extend its core functionality, and can provide everything from server side programming language support to authentication mechanism.

Apache uses one of following MPM (Multi-Processing Module) for handling incoming requests and processes them. It modifies basic functionality of the Apache server related to multi-thread and multi-processes style of working. Only one MPM can be loaded into the server at any time.

Types of MPM’s :-
Below is some basic details about MPM’s and there functionality.


Prefork MPM:- Prefork MPM launches multiple child processes. Each child process handle one connection at a time. Prefork uses high memory in comparison to worker MPM. Prefork is the default MPM used by Apache server. Prefork MPM always runs few minimum (MinSpareServers) defined processes as spare, so new requests do not need to wait for new process to start. It is higher memory consumption and lower performance over the newer Apache 2.0-based threaded MPM’s. It is Apache 1.3 based.

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 and has higher performance. It is Apache 2.0 based.

Event MPM:- It is pretty similar to worker MPM but it designed for managing high loads.
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.

Prefork MPM
·         Each request/connection is handled by a process
·         Multi-processes; 1 thread per process
·         Each request is handled by a different process.
·         This MPM is chosen mainly for stability and security.
·          
Worker MPM
·         Each request/connection is handled by a thread
·         Multi-processes; multiple threads per process
·         This MPM is chosen for better performance and lower memory consumption.
·          
Event MPM
·         It has been finally declared stable in Apache 2.4.
·         The way it function is similar to the Worker MPM.
·         it will assign a thread to a request.


MPM Specific :-

StartServers
StartServers sets how many server processes are created upon startup.

MaxRequestsPerChild
MaxRequestsPerChild sets the total number of requests each child server process serves before the child dies.

MaxClients
MaxClients sets a limit on the total number of server processes, or simultaneously connected clients, that can run at one time.

MinSpareServers and MaxSpareServers
These Values are only used with the prefork MPM.

The MaxSpareServers directive sets the desired maximum number of idle child server processes. An idle process is one which is not handling a request. If there are more than MaxSpareServers idle, then the parent process will kill off the excess processes..

The MinSpareServers directive sets the desired minimum number of idle child server processes. An idle process is one which is not handling a request. If there are fewer than MinSpareServers idle, then the parent process creates new children

MinSpareThreads and MaxSpareThreads
These values are only used with the worker MPM. The server checks the number of server threads waiting for a request and kills some if there are more than MaxSpareThreads or creates some if the number of servers is less than MinSpareThreads.

ThreadsPerChild
This value is only used with the worker MPM. It sets the number of threads within each child process.
The default value for this directive is 25.

Listen
The Listen command identifies the ports on which the Web server accepts incoming requests.

Include
Include allows other configuration files to be included at runtime.

User
The User directive sets the user name of the server process and determines what files the server is allowed to access.

Group
Specifies the group name of the Apache HTTP Server processes.

ServerName
ServerName specifies a hostname and port number for the server.

VirtualHost
<VirtualHost> and </VirtualHost> tags create a container outlining the characteristics of a virtual host. The VirtualHost container accepts most configuration directives.

Command to check MPM : httpd –V      

Below configurations are extracted from httpd.conf :-

# 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
# MaxRequestWorkers: maximum number of server processes allowed to start
# MaxConnectionsPerChild: maximum number of connections a server process serves
#                         before terminating
<IfModule mpm_prefork_module>
    StartServers             5
    MinSpareServers          5
    MaxSpareServers         10
    MaxRequestWorkers      250
    MaxConnectionsPerChild   0
</IfModule>

# worker MPM
# StartServers: initial number of server processes to start
# 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
# MaxRequestWorkers: maximum number of worker threads
# MaxConnectionsPerChild: maximum number of connections a server process serves
#                         before terminating
<IfModule mpm_worker_module>
    StartServers             3
    MinSpareThreads         75
    MaxSpareThreads        250
    ThreadsPerChild         25
    MaxRequestWorkers      400
    MaxConnectionsPerChild   0
</IfModule>

# event MPM
# StartServers: initial number of server processes to start
# 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
# MaxRequestWorkers: maximum number of worker threads
# MaxConnectionsPerChild: maximum number of connections a server process serves
#                         before terminating
<IfModule mpm_event_module>
    StartServers             3
    MinSpareThreads         75
    MaxSpareThreads        250
    ThreadsPerChild         25
    MaxRequestWorkers      400
    MaxConnectionsPerChild   0
</IfModule>




Refrence link :



Thanks :-)

No comments:

Post a Comment