Apache2 worker mode configuration

Source: Internet
Author: User

Apache MPM worker is a hybrid process/thread scheduling mechanism under multi-core CPU. It was introduced after apache version 2.2. Official introduction:

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 fewer system resources than a process-based server. however, it retains much of the stability of a process-based server by keeping multiple processes available, each with threads.

High processing efficiency is the biggest advantage of the worker mode.

For stability and cross-platform considerations, apache2 is compiled into the prefork mode by default (multi-process mode ). Therefore, to use the worker mode, we need to pay more for it.

Worker mode compilation and installation:

# For parameter explanations and more parameters, you can use the -- help parameter for help.
[Fancp @ redhatfancp httpd-2.2.17] $./configure -- prefix =/usr/local/apache2worker -- enable-so -- With-MPM = worker

[Fancp @ redhatfancp httpd-2.2.17] $ make clean [fancp @ redhatfancp httpd-2.2.17] $ make [fancp @ redhatfancp httpd-2.2.17] $ su [root @ redhatfancp httpd-2.2.17] $ mkdir/usr/local/apache2worker [root @ redhatfancp httpd-2.2.17] $ chown fancp/usr/local/apache2worker [root @ redhatfancp httpd-2.2.17] $ exit [fancp @ redhatfancp httpd-2.2.17] $ make install [fancp @ redhatfancp httpd-2.2.17] $/usr /local/apache2worker/bin/apachectl start

Five processes are displayed.

Fancp @ redhatfancp bin] $ PS-Ef | grep httpd
Fancp 15242 1 0 23:19? 00:00:00/usr/local/apache2worker/bin/httpd-K start
Fancp 15243 15242 0? 00:00:00/usr/local/apache2worker/bin/httpd-K start
Fancp 15244 15242 0? 00:00:00/usr/local/apache2worker/bin/httpd-K start
Fancp 15246 15242 0? 00:00:00/usr/local/apache2worker/bin/httpd-K start
Fancp 15248 15242 0? 00:00:00/usr/local/apache2worker/bin/httpd-K start
Fancp 15329 4762 0 00:00:00 pts/1 grep httpd

 

Observe the process list above and find that the PID of the parent process of process 15242 is 1, and it is also the parent process of process 15243,15244, 15246,152 48.

Why are five processes? What is the relationship between the five processes?

Mpm_default.h sets the default number of processes (default_start_daemon), the maximum number of processes (default_max_free_daemon), and the minimum number of processes (default_min_free_daemon ). These values are applied without parameter configuration. In version 2.2.17, the value of default_start_daemon is 3. Therefore, the composition of the above five processes is: one listen process, three Recv processes, and another process, which I don't know.

 

Modify the configuration file HTTP. conf, add the following content, and set the main thread to 1:

 

# 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 mpm_worker_module>
Startservers 1
Maxclients 15
Minsparethreads 1
Maxsparethreads 1
Threadsperchild 1
Maxrequestsperchild 0
</Ifmodule>

View Processes

[Fancp @ redhatfancp httpd-2.2.17] $/usr/local/apache2worker/bin/apachectl restart
[Fancp @ redhatfancp httpd-2.2.17] $ PS-Ef | grep httpd
Fancp 15242 1 0 23:19? 00:00:00/usr/local/apache2worker/bin/httpd-K start
Fancp 16035 15242 0? 00:00:00/usr/local/apache2worker/bin/httpd-K start
Fancp 16036 15242 0? 00:00:00/usr/local/apache2worker/bin/httpd-K start
Fancp 16041 4762 0 00:00:00 pts/1 grep httpd
[Fancp @ redhatfancp httpd-2.2.17] $

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.