Skip to content

Commit

Permalink
postgresql - adjust calculation of max database connections
Browse files Browse the repository at this point in the history
Signed-off-by: Simon L <szaimen@e.mail.de>
  • Loading branch information
szaimen committed Jul 23, 2023
1 parent b076d5e commit 7fa03da
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Containers/postgresql/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,10 @@ fi
if [ -f "/var/lib/postgresql/data/postgresql.conf" ]; then
echo "Setting max connections..."
MEMORY=$(awk '/MemTotal/ {printf "%d", $2/1024}' /proc/meminfo)
MAX_CONNECTIONS=$((MEMORY/50+3))
# Double amount of connections compared to max php-fpm children - so divided by 25 and not 50
MAX_CONNECTIONS=$((MEMORY/25))
# Subtract 3 connections, reserved for master
MAX_CONNECTIONS=$((MAX_CONNECTIONS-3))
if [ -n "$MAX_CONNECTIONS" ]; then
sed -i "s|^max_connections =.*|max_connections = $MAX_CONNECTIONS|" "/var/lib/postgresql/data/postgresql.conf"
fi
Expand Down

0 comments on commit 7fa03da

Please sign in to comment.