Created
February 27, 2014 02:01
-
-
Save renoirb/9242830 to your computer and use it in GitHub Desktop.
Making systematic variable configuration based on server provisioning.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{%- set ram_int = salt['grains.get']('mem_total', '1024') // 1024 -%} | |
{%- set max_clients = ram_int * 150 -%} | |
{%- if ram_int == 1 -%} | |
{%- set max_per_child = 1000 -%} | |
{%- elif ram_int == 2 -%} | |
{%- set max_per_child = 10000 -%} | |
{%- else -%} | |
{%- set max_per_child = 0 -%} | |
{%- endif -%} | |
# Edited by Salt Stack, generated with calculations | |
# based on the curernt system available resources | |
# | |
# see: | |
# - http://linuxstuffs.wordpress.com/apache-optimization/ | |
# - https://servercheck.in/blog/3-small-tweaks-make-apache-fly | |
# - http://coolpandaca.wordpress.com/2012/03/20/apache-mpm-worker-prefork-mod_php-mod_fcgid-mod_fastcgi-php-fpm-and-nginx/ | |
# | |
# Useful commands: | |
# | |
# The following commands are useful to calculate process usage and average | |
# memory usage on a given moment. | |
# | |
# - ps aux | grep 'apache2' | awk '{print $6/1024;}' | awk '{avg += ($1 - avg) / NR;} END {print avg " MB";}' | |
# - ps aux | grep 'apache2' | awk '{print $6/1024 " MB";}' | |
# | |
# Current system memory: {{ salt['grains.get']('mem_total', 'ERROR') }} | |
# | |
MinSpareServers 15 | |
MaxSpareServers 20 | |
ServerLimit {{ max_clients }} | |
MaxClients {{ max_clients }} | |
MaxRequestsPerChild {{ max_per_child }} | |
Timeout 150 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment