Skip to content

Instantly share code, notes, and snippets.

@turneliusz
turneliusz / auto-fpm-setup
Created March 1, 2017 08:43
Automatic setup of PHP-FPM pool max-children
#!/bin/bash -e
FPM_PROCESS_MEMORY_MB=60
RESERVE_INSTANCE_MEMORY=100
FPM_POOL_FILE=/etc/php/7.0/fpm/pool.d/www.conf
MEM_KB=`grep MemTotal /proc/meminfo | awk '{print $2}'`
MEM_FOR_FPM_MB=$(($MEM_KB/1024-$RESERVE_INSTANCE_MEMORY))
FPM_PROCESSES=$(($MEM_FOR_FPM_MB/$FPM_PROCESS_MEMORY_MB))