How to stop multiple httpd instance in macOS Catalina I am not well experienced with macOS yet and need some help to understand why there are multiple instances of httpd running on my macOS Catalina 10.15.4



Question:

If it is not required then how can I stop it all but the only one
which I am using for the development?

Updated

Result with App Processes - Hierarchically



Apache Location

Here is my apache location

➜  ~ which httpd
/usr/local/bin/httpd


apache files path

/usr/local/etc/httpd/httpd.conf
/usr/local/etc/httpd/extra/httpd-vhosts.conf
In the default config httpd starts a parent process usually owned by root which binds to port 80 (a port &lt; 1024), opens log files and spawns child processes. The child process(es) serve http requests. Depending on the number of requests and the level of concurrency they are dynamically added and released. It's completely normal to have several httpd processes in the process list.

You can tweak this by modifying several aspects of httpd.

Further reading with an explanation and pros &amp; cons: 


Apache docs: Apache MPM Common Directives &amp; Apache MPM prefork  
Liquidweb: Apache Performance Tuning: MPM Modules 




The number of possible child processes in the apache installed by brew (currently Apache/2.4.43; Server MPM: prefork) can be managed in the Supplemental configuration chapter of the config file. The relevant item is the Server-pool management (MPM specific) part. The number of child processes can be determined in its config file in the Prefork MPM section:


Modify Server-pool management (MPM specific) (~line 488 of /usr/local/etc/httpd/httpd.conf) from 

# Server-pool management (MPM specific)
#Include /usr/local/etc/httpd/extra/httpd-mpm.conf


to

# Server-pool management (MPM specific)
Include /usr/local/etc/httpd/extra/httpd-mpm.conf

Modify the prefork MPM config (starting at line 21 of /usr/local/etc/httpd/extra/httpd-mpm.conf)

from the default

# prefork MPM
# StartServers: number of server processes to start
# MinSpareServers: minimum number of server processes which are kept spare
# MaxSpareServers: maximum number of server processes which are kept spare
# MaxRequestWorkers: maximum number of server processes allowed to start
# MaxConnectionsPerChild: maximum number of connections a server process serves
#                         before terminating
&lt;IfModule mpm_prefork_module&gt;
    StartServers             5
    MinSpareServers          5
    MaxSpareServers         10
    MaxRequestWorkers      250
    MaxConnectionsPerChild   0
&lt;/IfModule&gt;


Process list:


to e.g.

# prefork MPM
# StartServers: number of server processes to start
# MinSpareServers: minimum number of server processes which are kept spare
# MaxSpareServers: maximum number of server processes which are kept spare
# MaxRequestWorkers: maximum number of server processes allowed to start
# MaxConnectionsPerChild: maximum number of connections a server process serves
#                         before terminating
&lt;IfModule mpm_prefork_module&gt;
    StartServers             1
    MinSpareServers          1
    MaxSpareServers          1
    MaxRequestWorkers      250
    MaxConnectionsPerChild   0
&lt;/IfModule&gt;


Process list:

Restart apache:

sudo apachectl -k restart





Speedtest (with ab -c 100 -n 1000 http://localhost:8080/index.html):

default prefork MPM config (StartServers/MinSpareServers/MaxSpareServers 5/5/10):

    Server Software:        Apache/2.4.43
    Server Hostname:        localhost
    Server Port:            8080

    Document Path:          /index.html
    Document Length:        45 bytes

    Concurrency Level:      100
    Time taken for tests:   1.075 seconds
    Complete requests:      1000
    Failed requests:        0
    Total transferred:      289000 bytes
    HTML transferred:       45000 bytes
    Requests per second:    929.81 [#/sec] (mean)
    Time per request:       107.549 [ms] (mean)
    Time per request:       1.075 [ms] (mean, across all concurrent requests)
    Transfer rate:          262.42 [Kbytes/sec] received

    Connection Times (ms)
                  min  mean[+/-sd] median   max
    Connect:        0    3   5.7      1      50
    Processing:     3  103  68.3     82     310
    Waiting:        2  101  67.1     81     309
    Total:         10  106  69.4     83     317

    Percentage of the requests served within a certain time (ms)
      50%     83
      66%    116
      75%    150
      80%    180
      90%    216
      95%    225
      98%    260
      99%    307
     100%    317 (longest request)


modified prefork MPM config (StartServers/MinSpareServers/MaxSpareServers 1/1/1):

    Server Software:        Apache/2.4.43
    Server Hostname:        localhost
    Server Port:            8080

    Document Path:          /index.html
    Document Length:        45 bytes

    Concurrency Level:      100
    Time taken for tests:   1.325 seconds
    Complete requests:      1000
    Failed requests:        0
    Total transferred:      289000 bytes
    HTML transferred:       45000 bytes
    Requests per second:    754.55 [#/sec] (mean)
    Time per request:       132.529 [ms] (mean)
    Time per request:       1.325 [ms] (mean, across all concurrent requests)
    Transfer rate:          212.96 [Kbytes/sec] received

    Connection Times (ms)
                  min  mean[+/-sd] median   max
    Connect:        0    4   8.9      1      55
    Processing:    10  125  56.4    116     231
    Waiting:        1  124  56.2    116     231
    Total:         20  129  53.1    119     232

    Percentage of the requests served within a certain time (ms)
      50%    119
      66%    136
      75%    170
      80%    186
      90%    214
      95%    221
      98%    229
      99%    231
     100%    232 (longest request)




This won't work for all apaches. I didn't get this to work with for example MAMP/MAMP Pro's apache!