Score:0

HTTPD + MPM_EVENT + PHP_FPM

mm flag

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
</IfModule>

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

djdomi avatar
za flag
i would just add a nginx infront of the setup. but however, what is the business relation in here?
siva nanda perumal avatar
mm flag
@djdomi, Yes instead of nginx I'm having httpd. I would expect this should serve the 500 request in 10s
ezra-s avatar
ru flag
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.
Score:0
ru flag

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
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.