You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Martin Knoblauch <kn...@knobisoft.de> on 2017/08/17 15:40:16 UTC

[users@httpd] Two questions on httpd tuning

Hi,

 this is for httpd-2.4.26 with the mpm_worker_module. I have one practical
and one more theoretical question.

First, is there a way to determine the maximum number of concurrent
requests that have been processed at any time since the last server
(re)start?

Second, if I have the default configuration and I ever want to increase
MaxRequestWorkers above 400 my understanding is that I need to either
increase ServerLimit or ThreadsPerChild (or adjust both). Which should I
touch first (why :-)?

Thanks a lot in advance
Martin
-- 
------------------------------------------------------
Martin Knoblauch
email: k n o b i AT knobisoft DOT de
www: http://www.knobisoft.de

Re: [users@httpd] Two questions on httpd tuning

Posted by Luca Toscano <to...@gmail.com>.
Hi Martin,

2017-08-18 10:09 GMT+02:00 Martin Knoblauch <kn...@knobisoft.de>:
>
>
>  Lets say I wanted to increase MaxRequestWorkers to e.g. 800. One of the
> several solutions would be to up ServerLimit to 32 and leave
> ThreadsPerChild at 25. But I could also leave ServerLimit at 16 and up
> ThreadsPerChild to 50. Or I could choose any combination where
> ServerLimit*ThreadsPerChild is bigger than 800. What I would like to know
> is which way to go. And why. What gives the best and most reliable results.
> Assumption is that there is plenty of free memory, CPU and network
> bandwidth available.
>

my personal recommendation would be to prefer increasing the number of
threads rather than the number of processes (threads are supposed to share
more and be less heavy to context switch for the OS, but on Linux this can
generate loooong discussions and flames so I will not go there :), but
you'd probably need to perform some load tests with different
configurations and see which one suits your system more. From the
reliability point of view I don't see much difference between the two
approaches, again testing would probably give you more datapoints to choose
the best approach for you use cases.

Interesting to read is also what mpm_event offers over mpm_worker and what
use cases it solves: https://httpd.apache.org/docs/2.4/mod/event.html

One thing that might also be good to check is the following:
https://httpd.apache.org/docs/current/mod/mpm_common.html#listencoresbucketsratio
When you read it please keep in mind that each process in mpm_worker/event
allocates one thread as listener, so there is contention for the listen
socket.

Luca

Re: [users@httpd] Two questions on httpd tuning

Posted by Martin Knoblauch <kn...@knobisoft.de>.
Hi Luca,


On Fri, Aug 18, 2017 at 9:01 AM, Luca Toscano <to...@gmail.com>
wrote:

> Hi Martin,
>
> 2017-08-17 17:40 GMT+02:00 Martin Knoblauch <kn...@knobisoft.de>:
>
>> Hi,
>>
>>  this is for httpd-2.4.26 with the mpm_worker_module. I have one
>> practical and one more theoretical question.
>>
>> First, is there a way to determine the maximum number of concurrent
>> requests that have been processed at any time since the last server
>> (re)start?
>>
>
> I would periodically poll https://httpd.apache.org/docs/
> 2.4/mod/mod_status.html and push metrics to a backend like
> graphite/prometheus/etc.
>

 OK. Clearly one way of doing it. Thanks.


>
>
>>
>> Second, if I have the default configuration and I ever want to increase
>> MaxRequestWorkers above 400 my understanding is that I need to either
>> increase ServerLimit or ThreadsPerChild (or adjust both). Which should I
>> touch first (why :-)?
>>
>
> From https://httpd.apache.org/docs/2.4/mod/worker.html:
>
> "ServerLimit is a hard limit on the number of active child processes, and
> must be greater than or equal to the MaxRequestWorkers directive divided by
> the ThreadsPerChild directive."
>
> Basically mpm_worker creates some processes (maximum ServerLimit) that in
> turn spawn ThreadsPerChild threads each, so you need to tune them to reach
> MaxRequestWorkers.
>
> Hope that helps :)
>

 Not on the second one. sorry :-)

 Lets say I wanted to increase MaxRequestWorkers to e.g. 800. One of the
several solutions would be to up ServerLimit to 32 and leave
ThreadsPerChild at 25. But I could also leave ServerLimit at 16 and up
ThreadsPerChild to 50. Or I could choose any combination where
ServerLimit*ThreadsPerChild is bigger than 800. What I would like to know
is which way to go. And why. What gives the best and most reliable results.
Assumption is that there is plenty of free memory, CPU and network
bandwidth available.

Cheers
Martin

-- 
------------------------------------------------------
Martin Knoblauch
email: k n o b i AT knobisoft DOT de
www: http://www.knobisoft.de

Re: [users@httpd] Two questions on httpd tuning

Posted by Luca Toscano <to...@gmail.com>.
Hi Martin,

2017-08-17 17:40 GMT+02:00 Martin Knoblauch <kn...@knobisoft.de>:

> Hi,
>
>  this is for httpd-2.4.26 with the mpm_worker_module. I have one practical
> and one more theoretical question.
>
> First, is there a way to determine the maximum number of concurrent
> requests that have been processed at any time since the last server
> (re)start?
>

I would periodically poll
https://httpd.apache.org/docs/2.4/mod/mod_status.html and push metrics to a
backend like graphite/prometheus/etc.


>
> Second, if I have the default configuration and I ever want to increase
> MaxRequestWorkers above 400 my understanding is that I need to either
> increase ServerLimit or ThreadsPerChild (or adjust both). Which should I
> touch first (why :-)?
>

From https://httpd.apache.org/docs/2.4/mod/worker.html:

"ServerLimit is a hard limit on the number of active child processes, and
must be greater than or equal to the MaxRequestWorkers directive divided by
the ThreadsPerChild directive."

Basically mpm_worker creates some processes (maximum ServerLimit) that in
turn spawn ThreadsPerChild threads each, so you need to tune them to reach
MaxRequestWorkers.

Hope that helps :)

Luca