How do I select which Apache MPM to use?

Better Stack Team
Updated on November 9, 2023

Selecting the appropriate Apache Multi-Processing Module (MPM) depends on various factors, such as the server environment, expected traffic, and the type of workload the server will handle. Here are common Apache MPMs and considerations for choosing the right one:

Prefork MPM:

  • Stability: Prefork MPM is known for stability and is often used when stability is a priority over performance.
  • Compatibility: It is well-suited for older modules that are not thread-safe.
  • Limited Scalability: It's less efficient in handling high traffic due to its process-based architecture.

Worker MPM:

  • Balanced Performance: It is a compromise between stability and performance.
  • Threaded Model: Utilizes multiple threads per process, which is more efficient than Prefork in handling connections.
  • Suitable for Moderate Load: Worker MPM can handle moderate to high loads efficiently.

Event MPM:

  • Improved Performance: Similar to Worker MPM but with further optimizations for handling multiple connections.
  • Reduced Memory Consumption: Efficiently manages connections and minimizes memory usage.
  • Optimal for High Loads: Event MPM performs well under high loads and is a good choice for heavily loaded servers.

Considerations for Choosing an MPM:

  1. Server Load and Traffic: Determine the expected traffic and workload. For high-traffic servers, the Worker or Event MPM might be more suitable due to their better scalability.
  2. Resource Utilization: Assess server resources. For systems with limited resources (like memory), the Prefork MPM might be more appropriate as it's less memory-intensive.
  3. Module Compatibility: If certain modules or applications used with Apache are not thread-safe, the Prefork MPM might be necessary.

Steps to Change the MPM:

  1. Check Enabled MPM:
    • Use httpd -V or apachectl -V command to check which MPM is currently enabled.
  2. Edit Apache Configuration:

    • Open the Apache configuration file (httpd.conf or a specific .conf file).
    • Look for the LoadModule lines for the MPM and change them accordingly. For example:

      # LoadModule mpm_prefork_module modules/
      LoadModule mpm_event_module modules/
  3. Restart Apache:

    • Restart Apache after making the changes:

      sudo systemctl restart apache2

When changing the MPM, it's essential to thoroughly test the web server to ensure compatibility with the existing applications and modules. Depending on the operating system and Apache version, some MPMs might have specific installation or configuration nuances. Always back up configurations before making changes and monitor the server's performance after switching MPMs.

Make your mark

Join the writer's program

Are you a developer and love writing and sharing your knowledge with the world? Join our guest writing program and get paid for writing amazing technical guides. We'll get them to the right readers that will appreciate them.

Write for us
Writer of the month
Marin Bezhanov
Marin is a software engineer and architect with a broad range of experience working...
Build on top of Better Stack

Write a script, app or project on top of Better Stack and share it with the world. Make a public repository and share it with us at our email.

or submit a pull request and help us build better products for everyone.

See the full list of amazing projects on github