Consulta de ajuste do Apache

1

Estou tentando ajustar os parâmetros no apache para um site de alto tráfego. Minhas especificações são

Ram : 12 GB RAM
CPU : 16 core

Parâmetros atuais

StartServers 5
MinSpareServers 5
MaxSpareServers 10
MinSpareServers 5
MaxSpareServers 10
ServerLimit 2500
MaxClients 2500
MaxRequestsPerChild 10000
KeepAlive Off
KeepAliveTimeout 5
MaxKeepAliveRequests 100

Quais são os valores recomendados para esses parâmetros de acordo com as especificações do meu servidor?

    
por Unnikrishnan 09.10.2014 / 15:38

1 resposta

1

Há um ótimo tutorial neste site como "calcular" o definições. (Tutorial também abaixo, caso o site fique offline)

Before customising the directives you need to understand how the directives work. Let me explain in plain English. Server will start 2 child processes which is determined by StartServers directive. Each process will start 20 threads which is determined by ThreadsPerChild directive so this means 2 process can service only 40 concurrent connections/clients(i.e. 20×2=40). So what if more requests come in.

Now if more concurrent users come, then another child process will start, that can serve another 20 users. But how many child processes can be started is controlled by ServerLimit parameter, this means that in the configuration above, I can have 10 child processes in total, with each child process can handle 20 thread, in total handling 10×20=200 concurrent users.

But there is a problem, number defined in MaxClients is 100 here, this means that after 5 child processes, no extra process will start since we have defined an upper cap of MaxClients. This also means that if I set MaxClients to 500, after 10 child processes and 200 connections, no extra process will start and we cannot service more than 200 concurrent clients even if we have increase the MaxClient parameter. In this case, we need to also increase ServerLimit to 500/20 i.e. MaxClients/ThreadsPerChild=25

Okay now you know the directives and how they work, the problem is how to calculate the directives. Let’s jump into calculating directive values.

You can use this shell script to determine an average amount of memory consumed by one Apache process. In addition to that it’ll show total amount of memory consumed by all Apache processes. Just unzip and execute with sh command. Accurate results will be shown when server is under heavy load.

The output

Apache Memory Usage (MB): 57.586 Average Proccess Size (MB): 10.2

Apache Memory Usage (MB): 57.586
Average Proccess Size (MB): 10.2   

if in average, let’s assume that one Apache process consumes 50MB RAM and server has got RAM is 2048MB, and you want to leave 512MB for the rest of the processes, then:

MaxClients = (2048MB – 512MB)/10MB = 153.6 ~ 153
    
por 10.10.2014 / 14:12