From 2a6fe801bc59514708ac831c38e3ed3d05465eff Mon Sep 17 00:00:00 2001 From: He Weiwei Date: Tue, 14 Jul 2020 07:33:01 +0000 Subject: [PATCH] chore(db): change max_connections of postgres to 1024 Signed-off-by: He Weiwei --- make/harbor.yml.tmpl | 4 ++-- make/photon/db/docker-entrypoint.sh | 12 +++++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/make/harbor.yml.tmpl b/make/harbor.yml.tmpl index 4f7aafedd..6d6228609 100644 --- a/make/harbor.yml.tmpl +++ b/make/harbor.yml.tmpl @@ -40,8 +40,8 @@ database: # The maximum number of connections in the idle connection pool. If it <=0, no idle connections are retained. max_idle_conns: 50 # The maximum number of open connections to the database. If it <= 0, then there is no limit on the number of open connections. - # Note: the default number of connections is 100 for postgres. - max_open_conns: 100 + # Note: the default number of connections is 1024 for postgres of harbor. + max_open_conns: 1000 # The default data volume data_volume: /data diff --git a/make/photon/db/docker-entrypoint.sh b/make/photon/db/docker-entrypoint.sh index abfabe4ec..732f244f0 100644 --- a/make/photon/db/docker-entrypoint.sh +++ b/make/photon/db/docker-entrypoint.sh @@ -107,4 +107,14 @@ EOSQL echo fi -postgres -D $PGDATA +POSTGRES_PARAMETER='' + +file_env 'POSTGRES_MAX_CONNECTIONS' '1024' +# The max value of 'max_connections' is 262143 +if [ $POSTGRES_MAX_CONNECTIONS -le 0 ] || [ $POSTGRES_MAX_CONNECTIONS -gt 262143 ]; then + POSTGRES_MAX_CONNECTIONS=262143 +fi + +POSTGRES_PARAMETER="${POSTGRES_PARAMETER} -c max_connections=${POSTGRES_MAX_CONNECTIONS}" + +postgres -D $PGDATA $POSTGRES_PARAMETER