Httpd worker MPM Concepts

From NovaOrdis Knowledge Base
Revision as of 01:46, 2 January 2017 by Ovidiu (talk | contribs) (→‎Overview)
Jump to navigation Jump to search

Internal

Overview

When configured in worker MPM mode, the httpd web server functions as a hybrid multi-process/multi-threaded web server. The server uses multiple O/S processes, each of them running multiple threads, to serve requests.

worker MPM support has be be explicitly compiled into the binary, it is not available by default. See the "Compilation" section to learn how to configure httpd with worker support and how to check whether worker support has been correctly installed.

A single control process (the parent) is responsible for launching child processes. Each child process creates a fixed number of server threads as specified in the [ThreadsPerChild|HttpdWorkerMPM#ThreadsPerChild] directive, as well as a listener thread which listens for connections and passes them to a server thread for processing when they arrive.

Apache always tries to maintain a pool of spare or idle server threads, which stand ready to serve incoming requests. In this way, clients do not need to wait for a new threads or processes to be created before their requests can be served. The number of processes that will initially launched is set by the [StartServers|HttpdWorkerMPM#StartServers] directive. During operation, Apache assesses the total number of idle threads in all processes, and forks or kills processes to keep this number within the boundaries specified by [MinSpareThreads|HttpdWorkerMPM#MinSpareThreads] and [MaxSpareThreads|HttpdWorkerMPM#MaxSpareThreads]. What happens if all processes have at least an active threads, at any time? Does Apache has a mechanism that marks a process for shut down and let it bleed of active requests? Since this process is very self-regulating, it is rarely necessary to modify these directives from their default values. The maximum number of clients that may be served simultaneously (i.e., the maximum total number of threads in all processes) is determined by the [MaxClients|HttpdWorkerMPM#MaxClients] directive. The maximum number of active child processes is determined by the MaxClients directive divided by the [ThreadsPerChild|HttpdWorkerMPM#ThreadsPerChild] directive.

Two directives set hard limits on the number of active child processes and the number of server threads in a child process, and can only be changed by fully stopping the server and then starting it again. [ServerLimit|HttpdWorkerMPM#ServerLimit] is a hard limit on the number of active child processes, and must be greater than or equal to the MaxClients directive divided by the [ThreadsPerChild|HttpdWorkerMPM#ThreadsPerChild] directive. [ThreadLimit|HttpdWorkerMPM#ThreadLimit] is a hard limit of the number of server threads per child process, and must be greater than or equal to the ThreadsPerChild directive. If non-default values are specified for these directives, they should appear before other worker directives.

ServerLimit is a hard limit (can only be changed by fully stopping the server) of active child processes.

Configuration

worker MPM Configuration




TODO, copy over from https://home.feodorov.com:9443/wiki/Wiki.jsp?page=HttpdWorkerMPM