I have created a docker container with the following

OS: Debian 11

WebServer: httpd2.4 (Enabled mpm_event)

Backend: PHP-FPM

Docker is running in EC2 and I have given 10GB RAM and 5CPU for the docker container.

Everything is working on the UI and my application is good. Now I'm looking forward to optimizing the server to increase the simultaneous requests and performance.

So, what I have done is

httpd.conf (/usr/local/apache2/conf/httpd.conf)

Enabled the mpm_event module and commented on the mpm_prefork and mpm_worker modules. Added the following configuration

<IfModule mpm_event_module>
        ServerLimit     256
        StartServers    125
        MinSpareThreads 100
        MaxSpareThreads 150
        ThreadLimit     64
        ThreadsPerChild 25
        MaxRequestWorkers       2000
        MaxConnectionsPerChild  10000

PHP-FPM configuration

pm = dynamic            
pm.max_children = 256      
pm.start_servers = 125   
pm.min_spare_servers = 100     
pm.max_spare_servers = 150
pm.max_requests = 1000
m.max_spawn_rate = 100

When I try to check the load testing with apache benchmark `ab -n 500 -c 100 "http://localhost/test.php" takes 35s to load.

Before the mpm_event module, I used prefork and I got the response in 16s. Not sure what I'm missing

  • i would just add a nginx infront of the setup. but however, what is the business relation in here?
    – djdomi
    Mar 15 at 6:01
  • @djdomi, Yes instead of nginx I'm having httpd. I would expect this should serve the 500 request in 10s Mar 15 at 9:00
  • 256 child processes each with 25 threads, it is basically nonsense. You could just have 4 child processes with 500 threads each or perhaps 200 threads each process, but you certainly do not need 256 processes, why would one use mpm_event to have 257 child processes?. And you don't need nginx on top of apache, that's another nonsense. Whatever you have configured right should do fine. Mar 25 at 18:10

1 Answer 1


Use a more correct approach to a threaded mpm like event. You certainly do not need and shouldn't use so many child processes. Atlhough my hint will not be perfect science at least consider the amount of cpu cores you have available before assigning processes like crazy.

Here is a more sane approach to achieve 2000 workers.

StartServers            1
ServerLimit             4
MinSpareThreads         100
MaxSpareThreads         1200
ThreadsPerChild         500
ThreadLimit             500
MaxRequestWorkers       2000
MaxConnectionsPerChild  100000000

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.