When running high-traffic websites on multi-core servers (like your dual quad Xeon setup), the traditional prefork MPM becomes inefficient due to its process-based architecture. Worker MPM's hybrid multi-process/multi-threaded approach offers:
- Lower memory footprint (shared memory between threads)
- Better CPU utilization (threads handle concurrent connections)
- Higher scalability (handles more requests with same resources)
First, check your current MPM configuration:
httpd -V | grep -i mpm
Server MPM: prefork
Install the worker module if not present:
yum install httpd-worker
Edit /etc/httpd/conf.modules.d/00-mpm.conf:
# Comment out prefork module
# LoadModule mpm_prefork_module modules/mod_mpm_prefork.so
# Uncomment worker module
LoadModule mpm_worker_module modules/mod_mpm_worker.so
Update worker configuration in /etc/httpd/conf/httpd.conf:
<IfModule mpm_worker_module>
StartServers 2
MinSpareThreads 25
MaxSpareThreads 75
ThreadLimit 64
ThreadsPerChild 25
MaxRequestWorkers 150
MaxConnectionsPerChild 0
</IfModule>
For a dual quad Xeon server, consider these optimized settings based on your traffic:
MaxRequestWorkers = (Total RAM - Other Services) / Average Thread Memory Usage
ThreadsPerChild = (CPU Cores * 2) + 1
After restarting Apache, verify the change:
systemctl restart httpd
httpd -V | grep -i mpm
Server MPM: worker
Monitor performance improvements using:
apachetop
htop -u apache
Be aware that some modules aren't thread-safe. If you use PHP, switch to PHP-FPM:
yum remove mod_php
yum install php-fpm
systemctl enable php-fpm
Update your vhost configuration:
<FilesMatch \.php$>
SetHandler "proxy:fcgi://127.0.0.1:9000"
</FilesMatch>
Apache HTTP Server offers different Multi-Processing Modules (MPMs) to handle client requests. The two most common for Linux systems are:
- Prefork MPM: Creates separate child processes for each request, each with its own memory space
- Worker MPM: Uses a hybrid approach with multiple processes, each containing multiple threads
For high-traffic websites on multi-core servers (like your dual quad Xeon), Worker MPM provides significant advantages:
# Key benefits:
- Lower memory footprint (shared memory between threads)
- Better CPU utilization (threads can handle concurrent requests)
- Improved performance under heavy loads
- Better scaling on multi-core systems
Here's how to switch from Prefork to Worker MPM on CentOS 64-bit:
# 1. Check current MPM module
httpd -V | grep -i mpm
# 2. Install Worker MPM package (if not installed)
yum install httpd-worker
# 3. Disable Prefork module
yum remove httpd-prefork
# 4. Edit Apache configuration
vi /etc/httpd/conf/httpd.conf
Update your httpd.conf with these Worker-specific settings:
<IfModule mpm_worker_module>
StartServers 2
MinSpareThreads 25
MaxSpareThreads 75
ThreadLimit 64
ThreadsPerChild 25
MaxRequestWorkers 150
MaxConnectionsPerChild 0
</IfModule>
After restarting Apache (systemctl restart httpd
), verify the change:
# Verify running MPM
apachectl -V | grep -i mpm
# Monitor performance
apachectl status
htop
If you encounter problems:
# Check error logs
tail -f /var/log/httpd/error_log
# Common solutions:
- PHP applications may need php-zts package
- Ensure all modules are thread-safe
- Adjust ThreadsPerChild based on your RAM
Here's a simple benchmark comparison script:
ab -n 10000 -c 100 http://yourserver.com/test.html
# Compare results between:
# - Prefork: ~850 req/sec
# - Worker: ~1200 req/sec (typical improvement)