Skip to content

Technology Forum

SEO, Speed Up website, Server Optimization, Linux, Open Source Softwares

  • Home
  • General
    • Web Server
    • Website Formatting
  • IT Companies
  • Optimization
    • PHP
  • Linux
  • Home
  • Optimization
  • PHP
  • Apache Prefork versus Worker
Optimization
Add Trailing Slash to URL (.htaccess)
CSS
Word Wrap long text in HTML
Optimization
Check PageSpeed
Plesk Panel
Plesk: Self-Signed SSL Certificate
Plesk Panel
Plesk: Disable Mail Service for domain
Linux
Manage and Tweak Dedicated Linux Hosting Web Server

Apache Prefork versus Worker

Posted on October 5, 2015October 5, 2015 By admin No Comments on Apache Prefork versus Worker
PHP, Web Server

Prefork:

The prefork MPM uses multiple child processes with one thread each. Each process handles one connection at a time. On many systems, prefork is comparable in speed to worker, but uses more memory. Prefork’s threadless design has advantages over worker in some situations: it can be used with non-thread-safe third-party modules, and it is easier to debug on platforms with poor thread debugging support.

Advantages:

  • Developed in Apache 1
  • Multiple child processes, 1 thread per child process, child processes handle requests
  • Better isolation and stability
  • Tested to work correctly with Parallels Plesk

Disadvantages:

  • Has higher memory consumption and lower performance over the threaded MPMs

Worker:

The worker MPM uses multiple child processes with many threads each. Each thread handles one connection at a time. Worker is generally a good choice for high-traffic servers because it has a smaller memory footprint than the prefork MPM.

Advantages:

  • Developed in Apache 2 in addition to prefork module
  • Multiple processes, many threads per process, threads handle requests
  • Uses less memory and provides higher performance

Disadvantages:

  • Does not provide the same level of isolation request-to-request as a process-based MPM does
  • If single thread is suspended/out of control, the entire process will be terminated, affecting all of the threads
  • Requires a thread-safe processor to handle dynamic content
  • Not supported by Parallels PleskEach module has a different set of the configuration directives in the Apache webserver configuration file:

Prefork:

<IfModule prefork.c>
StartServers       8
MinSpareServers    5
MaxSpareServers   20
ServerLimit      256
MaxClients       256
MaxRequestsPerChild 4000
</IfModule>

Worker:

<IfModule worker.c>
 StartServers         2
 MaxClients         150
 MinSpareThreads     25
 MaxSpareThreads     75
 ThreadsPerChild     25
 MaxRequestsPerChild  0
 </IfModule>

Information:

In the RedHat-based Linux distributions, Apache webserver is configured to run with the prefork module by default. Technically, you could switch it to “worker” if you decide that this would suit your needs better, however keep in mind the warning below.

Warning: Parallels Plesk Panel was not tested with Apache MPM worker and installing it on Debian/Ubuntu will lead to removal of psa package.

If you still wish to switch to worker module, it is sufficient to uncomment this directive in /etc/sysconfig/httpd file:

# grep HTTPD= /etc/sysconfig/httpd
#HTTPD=/usr/sbin/httpd.worker

and restart Apache:

# /etc/init.d/httpd restart

Note, that the worker MPM assumes a special PHP module to be configured/loaded by the Apache webserver:

# cat /etc/httpd/conf.d/php.conf|grep -A3 "worker.c"
<IfModule worker.c>
 LoadModule php5_module modules/libphp5-zts.so
</IfModule>

In the end, the question that is frequently asked by customers and engineers is: how do I determine which MPM module the server is running on?

First, use ps utility to determine the command line of running Apache process:

 # ps aux | grep -v grep | egrep "apache|httpd"
 root      1684  0.0  1.4 284484 14888 ?        Ss   17:52   0:00 /usr/sbin/httpd
 apache    3101  0.0  0.7 284484  7596 ?        S    18:02   0:00 /usr/sbin/httpd 

and check which module it is running by using this command:

 # /usr/sbin/httpd -l | egrep "prefork|worker" 

Alternatively, check /etc/sysconfig/httpd configuration file:

 # grep -B 5 HTTPD= /etc/sysconfig/httpd
 # The default processing model (MPM) is the process-based
 # "prefork" model. A thread-based model, "worker," is also
 # available, but does not work with some modules (such as PHP).
 # The service must be stopped before changing this variable.
 #
 #HTTPD=/usr/sbin/httpd.worker 
Tags: Odin Plesk

Post navigation

❮ Previous Post: Remove Apps from Windows 10
Next Post: Plesk: Self-Signed SSL Certificate ❯

You may also like

PHP
Plesk/Odin Services Structure
Web Server
Security Tips
PHP
TIPS
PHP
Remove Apps from Windows 10

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

View Posts

  • PHP FPM modification – Plesk
  • HTML: Link rel – Preload
  • HTML: Attributes of rel
  • Linux Commands
  • Security HTTP Headers

Categories

  • Domain Name
  • General
    • Servers
    • Web Server
    • Website Formatting
  • IT Companies
  • Linux
  • MySQL
  • Optimization
    • PHP
  • Troubleshooting
  • Web Hosting Control Panel
    • Plesk Panel
  • Websites
    • CSS
    • HTML
    • Optimization
  • Windows
    • Windows 10

Recent Posts

  • PHP FPM modification – Plesk
  • HTML: Link rel – Preload
  • HTML: Attributes of rel
  • Linux Commands
  • Security HTTP Headers

Copyright © 2025 Technology Forum.

Theme: Oceanly News by ScriptsTown