Configuração WINNT Apache MPM “ThreadsPerChild” no Windows Server 2008 R2

1

Estou recebendo um erro e não consigo iniciar o Apache quando configuro meu ThreadPerChild para 200, embora eu ainda tenha 60% de RAM livre. Servidor é o Windows Server 2008 R2 com 4 GB de RAM. Como utilizar mais RAM para o apache nesse caso?

Minha configuração do Apache MPM:

# WinNT MPM
# ThreadsPerChild: constant number of worker threads in the server process
# MaxRequestsPerChild: maximum  number of requests a server process serves
# Win32DisableAcceptEx: Use accept() rather than AcceptEx() to accept network connections
<IfModule mpm_winnt_module>
   ThreadStackSize 8388608
    ThreadsPerChild      170
    MaxRequestsPerChild    0
    #Win32DisableAcceptEx
</IfModule>

O que eu recebo no error_log do apache:

[Thu Dec 01 18:23:04.459113 2016] [mpm_winnt:notice] [pid 3396:tid 288] AH00354: Child: Starting 200 worker threads.

[Thu Dec 01 18:23:04.459113 2016] [mpm_winnt:crit] [pid 3396:tid 288] (OS 8)Not enough storage is available to process this command. : AH00355: Child: CreateThread failed. Unable to create all worker threads. Created 190 of the 200 threads requested with the ThreadsPerChild configuration directive.

[Thu Dec 01 18:23:04.474714 2016] [mpm_winnt:notice] [pid 3644:tid 380] AH00422: Parent: Received shutdown signal --

EDIT: 9 de dezembro de 2016:

Seguiu esta página link para alterar o IRPStackSize no Registro para 20 e 25. Ainda não foi possível iniciar Servidor Apache.

Obrigado.

    
por user3162662 02.12.2016 / 07:04

2 respostas

1

A configuração de threads do módulo de multiprocessamento (mpm) em qualquer sistema está vinculada a certas restrições, limitações do sistema e configurações de fail-safe compiladas, conforme descrito no artigo Diretivas comuns do Apache MPM

ThreadsPerChild Directive

This directive sets the number of threads created by each child process. The child creates these threads at startup and never creates more. If using an MPM like mpm_winnt, where there is only one child process, this number should be high enough to handle the entire load of the server. If using an MPM like worker, where there are multiple child processes, the total number of threads should be high enough to handle the common load on the server.

Diretiva ThreadLimit

Special care must be taken when using this directive. If ThreadLimit is set to a value much higher than ThreadsPerChild, extra unused shared memory will be allocated. If both ThreadLimit and ThreadsPerChild are set to values higher than the system can handle, Apache httpd may not start or the system may become unstable. Do not set the value of this directive any higher than your greatest predicted setting of ThreadsPerChild for the current run of Apache httpd.

E eles também apontam que ...

The default value for ThreadLimit is 1920 when used with mpm_winnt and 64 when used with the others.

Existe também um limite compilado codificado que você pode contornar recompilando o código como explicado aqui:

There is a hard limit of ThreadLimit 20000 (or ThreadLimit 100000 with event, ThreadLimit 15000 with mpm_winnt) compiled into the server. This is intended to avoid nasty effects caused by typos. To increase it even further past this limit, you will need to modify the value of MAX_THREAD_LIMIT in the mpm source file and rebuild the server.

Diretiva ThreadStackSize

The ThreadStackSize directive sets the size of the stack (for autodata) of threads which handle client connections and call modules to help process those connections. In most cases the operating system default for stack size is reasonable, but there are some conditions where it may need to be adjusted:

Quais são ...

It is recommended to not reduce ThreadStackSize unless a high number of threads per child process is needed. On some platforms (including Linux), a setting of 128000 is already too low and causes crashes with some common modules.

Solução

Se você estiver indo para aumentar a diretiva ThreadsPerChild, então você terá que alinhar a diretiva ThreadLimit para o mesmo valor ou apenas um pouco maior, enquanto reduz adicionalmente a diretiva ThreadStackSize para um valor menor que o padrão, mantendo um sistema estável .

Uma possível solução seria:

<IfModule mpm_winnt_module>
    ThreadStackSize  6291456
    ThreadsPerChild      200
    ThreadLimit          200
    MaxRequestsPerChild    0
    #Win32DisableAcceptEx
</IfModule>

Você terá que brincar um pouco com esses valores para determinar a configuração que permitirá que você execute um sistema estável com a configuração máxima de ThreadsPerChild.

    
por 13.01.2017 / 11:52
1

Essa pessoa diz que, ao usar o Windows de 64 bits e o Apache, eles conseguiram maximizar sua ThreadsPerChild .

link

Today I've tried the same configuration as described above but using x64 system:
Windows Server 2012 (x64)
Apache 2.4.7 VC11 64bit
mod_fcgid 2.3.9
PHP 5.4.24 VC11 Non-thread-safe

However, on a 64bit system two problems went away:
1. mpm ThreadsPerChild can now be set to 15000

    
por 13.01.2017 / 07:18