From 7076f6176b5a810ffe544f55f3bfc184adf77a41 Mon Sep 17 00:00:00 2001 From: Hamza Date: Mon, 16 Sep 2024 13:51:30 +0200 Subject: [PATCH] SS-1089 Add connection pooling (#53) --- serve/templates/studio-settings-configmap.yaml | 9 ++++++++- serve/values.yaml | 7 +++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/serve/templates/studio-settings-configmap.yaml b/serve/templates/studio-settings-configmap.yaml index 58e4d7d..3de1364 100644 --- a/serve/templates/studio-settings-configmap.yaml +++ b/serve/templates/studio-settings-configmap.yaml @@ -236,7 +236,14 @@ data: DATABASES = { 'default': { - 'ENGINE': 'django.db.backends.postgresql_psycopg2', + "ENGINE": "django.db.backends.postgresql", + "OPTIONS": { + "pool": { + "min_size": {{ .Values.studio.connectionPool.minSize | default 2 }}, + "max_size": {{ .Values.studio.connectionPool.maxSize | default 4 }}, + "timeout": {{ .Values.studio.connectionPool.timeout | default 10 }}, + } + }, 'NAME': '{{ .Values.postgresql.global.postgresql.auth.database }}', 'USER': '{{ .Values.postgresql.global.postgresql.auth.username }}', 'PASSWORD': os.environ.get('POSTGRES_PASSWORD'), diff --git a/serve/values.yaml b/serve/values.yaml index e8d9726..03521a3 100644 --- a/serve/values.yaml +++ b/serve/values.yaml @@ -150,6 +150,10 @@ studio: enabled: false fields: - '' + connectionPool: + minSize: 2 + maxSize: 4 + timeout: 10 #kubernetes config kubeconfig: "" @@ -191,6 +195,9 @@ postgresql: service: ports: postgresql: 5432 + extraEnvVars: + - name: POSTGRESQL_MAX_CONNECTIONS + value: "300" persistence: enabled: true size: "10Gi"