Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

On prefork and worker Mode switching of Apache

2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

problem

On Prima/Plesk/Virtuozzo, apache uses the rpm package of httpd-2.0.5x that comes with the system.

On redhat linux, prefork mode is used by default instead of worker mode

How do I switch between the two?

Solution

Apache HTTP server is designed as a powerful and flexible server that can work on multiple platforms and different environments.

Different platforms and different environments often produce different requirements, or different methods are used to achieve the same best results.

Apache adapts to a large number of different environments with its modular design.

This design enables webmasters to determine different additional functions of the server by loading different modules at compile time and run time.

Apache2.0 extends this modular design to the basic functions of the web server.

This version comes with the selection of a multiplexing module (MPM) to handle network port binding,

Accept requests and assign child processes to process them.

For example, if you need better scalability, you can choose threaded MPM like worker or event

And need better stability and compatibility to adapt to some old software can use prefork.

On as4, the major version of Redhat Linux, the apache version is httpd-2.0.5x

The default is prefork mode, mainly for stability reasons.

To switch to worker mode, log in to linux and do the following:

Enter the / usr/sbin directory

Cd / usr/sbin

Rename the current prefork mode startup file

Mv httpd httpd.prefork

Rename the startup file in worker mode

Mv httpd.worker httpd

Modify the configuration file vi / etc/httpd/conf/httpd.conf

Find the following paragraph, and modify the load and other parameters as appropriate:

StartServers 5

ThreadLimit 200

ServerLimit 50

MaxClients 2000

MinSpareThreads 25

MaxSpareThreads 200

ThreadsPerChild 100

MaxRequestsPerChild 50

Restart the service

/ etc/init.d/httpd restart

You can start apache2 in worker mode.

Summary:

1. There is no concept of threading in prefork. It is a multi-process model. One process handles a connection; it is stable; and it responds quickly. The disadvantage is that it consumes a lot of memory when the number of connections is relatively large.

2. Worker is a multi-process and multi-threaded model, in which a process has multiple threads, and each thread processes a connection. Compared with prefork, worker mode saves more memory resources of the system. However, you need to pay attention to the compatibility of Apache in worker mode with program modules such as php.

3. Event is a variant of worker mode, which separates the service process from the connection and can withstand a higher concurrent load than worker mode when KeepAlive is enabled. Event mode does not support https access very well (issues related to HTTP authentication).

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report