0

I have asked this question before on Stackoverflow, but this seems to be a better place to ask it.

I have a httpd process running (just apache2), with PHP. In index.php I have the following code in the file:

echo shell_exec("sudo -u apache python3 /root/folder/script.py 2>&1");

Which should execute a a program (which its doing nicely). The program takes ~40 seconds to return something, so it takes a bit. Ive created another python program which is multithreaded. Which makes a request 400 times on the same time to the url, which should start 400 processes.

When I run the command top -c, I see that the CPU is only at 9% while that should be higher. I tried the next command, ps xa | grep apache | wc -l. That returns 101 processes, I've done the command multiple times and its always at 101.

Before I did the command ps xa | grep apache | wc -l, I first made a mistake and tried ps xa | grep apache2 | wc -l, I don't run apache2, but that still gave me the numer 1. So my theory is that 101 - 1 = 100. Which is a too beautiful number.

So this should be some type of maximum / limit / cap. Where can I configure this?

Thanks for your time

===== EDIT =====

I think its queue'ing the requests, while when I login into the server and run the python script manually, the script just normally works without any slow downs etc.

===== EDIT 2 =====

Content of /etc/httpd/conf.mudles.d/00-mpm.conf:

# Select the MPM module which should be used by uncommenting exactly
# one of the following LoadModule lines.  See the httpd.conf(5) man
# page for more information on changing the MPM.

# prefork MPM: Implements a non-threaded, pre-forking web server
# See: http://httpd.apache.org/docs/2.4/mod/prefork.html
#
# NOTE: If enabling prefork, the httpd_graceful_shutdown SELinux
# boolean should be enabled, to allow graceful stop/shutdown.
#
#LoadModule mpm_prefork_module modules/mod_mpm_prefork.so

# worker MPM: Multi-Processing Module implementing a hybrid
# multi-threaded multi-process web server
# See: http://httpd.apache.org/docs/2.4/mod/worker.html
#
#LoadModule mpm_worker_module modules/mod_mpm_worker.so

# event MPM: A variant of the worker MPM with the goal of consuming
# threads only for connections with active processing
# See: http://httpd.apache.org/docs/2.4/mod/event.html
#
LoadModule mpm_event_module modules/mod_mpm_event.so

The configs are basically still default, I haven't changed them at all

Aaron
  • 1
  • 1
  • It sounds like you need to look into your Apache config - there are different modules which could be in use, but look for files with "Worker" directives and config files with mpm in the name. – davidgo May 15 '20 at 21:35
  • @davidgo thanks for your response! Checkout edit 2. I've added the mpm config which I could find, but no Worker directories? Thanks! – Aaron May 16 '20 at 08:16
  • I don't use mpm_event myself, but it looks like it can be tuned - have a read of https://asysadmin.tips/tuning-apache-mpm-event-parameters-serve-high-traffic-website/ – davidgo May 16 '20 at 08:42

0 Answers0