Skip to content

Instantly share code, notes, and snippets.

@DaffyDuke
Last active March 4, 2017 14:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DaffyDuke/394a5f229a0b8aeec2aab42e02e8bacd to your computer and use it in GitHub Desktop.
Save DaffyDuke/394a5f229a0b8aeec2aab42e02e8bacd to your computer and use it in GitHub Desktop.
Administration Web

APACHE PROCESSES / THREADS TUNING

The goal of this doc is to give you some tips to help tuning the worker MPM of the Apache web server.

The worker MPM

This Multi-Processing Module (MPM) implements a hybrid multi-process multi-threaded server. By using threads to serve requests, it is able to serve a large number of requests with less system resources than a process-based server. Yet it retains much of the stability of a process-based server by keeping multiple processes available, each with many threads.

The most important directives used to control this MPM are ServerLimit (default is 16), which controls the max number of process started by Apache, ThreadsPerChild (default is 25), which controls the number of threads deployed by each child process and MaxClients (default is 256), which controls the maximum total number of threads that may be launched and which can't be greater than (ServerLimit * ThreadsPerChild). The memory impact

The first thing to keep in mind, is that changing the value of MaxClients will have a direct impact on the amount of memory your Apache instance will use. To give you an idea, each process will use around 15MB of memory (depending on the modules loaded) and each thread will use around 128KB. Has you can see the worker parameters and the amount of memory used are tighted together and changing one value will change all the others. So the first thing to do is to make a choice on which value among MaxClients and Memory is the most important for you, fix that value and determine the other value with the following rules.

Calculation rules

All calculation rules are deduced from the following assertions :

Memory = ServerLimit * ProcessSize + ThreadSize * ThreadsPerChild
MaxClient = ServerLimit * ThreadsPerChild

Find MaxClient with fixed Memory size

MaxClient = (Memory * ThreadsPerChild) / (ProcessSize + ThreadSize * ThreadsPerChild)

Find max Memory usage with fixed MaxClient

Memory = MaxClient(ProcessSize + ThreadSize * ThreadsPerChild) /
ThreadsPerChild

Set all other values

As Threads are much more light than processes, we'll assume that we always set TheadsPerChild to its maximum value.

ThreadsPerChild = 64

With the second assertion we can deduce the ServerLimit value :

ServerLimit = MaxClient / 64
# Server Parsed HTML
pour pouvoir executer des commandes dans les fichiers HTML (<!--#exec cmd="..."--> ou <!--#exec cgi="..."--> ) :
ajouter cette ligne dans le mime.types, pour parser les .shtml
type=magnus-internal/parsed-html exts=shtml
et ajouter cette ligne dans l'obj.conf
Service method="(GET|HEAD)" type="magnus-internal/parsed-html" fn="parse-html"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment