From dcbd89ff7ce38fe664559942f2277634202eea97 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Thu, 10 Feb 2022 09:27:54 +0100 Subject: [PATCH] :sparkles: Increase default max connection pool size to 60. --- backend/src/app/db.clj | 26 ++++++++++++++++++-------- backend/src/app/main.clj | 2 +- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/backend/src/app/db.clj b/backend/src/app/db.clj index a4976b47b..80fb8d5c9 100644 --- a/backend/src/app/db.clj +++ b/backend/src/app/db.clj @@ -50,16 +50,26 @@ (declare instrument-jdbc!) (declare apply-migrations!) -(s/def ::name keyword?) -(s/def ::uri ::us/not-empty-string) -(s/def ::min-pool-size ::us/integer) +(s/def ::connection-timeout ::us/integer) (s/def ::max-pool-size ::us/integer) (s/def ::migrations map?) +(s/def ::min-pool-size ::us/integer) +(s/def ::name keyword?) +(s/def ::password ::us/string) (s/def ::read-only ::us/boolean) +(s/def ::uri ::us/not-empty-string) +(s/def ::username ::us/string) +(s/def ::validation-timeout ::us/integer) (defmethod ig/pre-init-spec ::pool [_] - (s/keys :req-un [::uri ::name ::min-pool-size ::max-pool-size] - :opt-un [::migrations ::mtx/metrics ::read-only])) + (s/keys :req-un [::uri ::name ::username ::password] + :opt-un [::min-pool-size + ::max-pool-size + ::connection-timeout + ::validation-timeout + ::migrations + ::mtx/metrics + ::read-only])) (defmethod ig/init-key ::pool [_ {:keys [migrations metrics name] :as cfg}] @@ -110,11 +120,11 @@ (.setPoolName (d/name (:name cfg))) (.setAutoCommit true) (.setReadOnly read-only) - (.setConnectionTimeout 10000) ;; 10seg - (.setValidationTimeout 10000) ;; 10seg + (.setConnectionTimeout (:connection-timeout cfg 10000)) ;; 10seg + (.setValidationTimeout (:validation-timeout cfg 10000)) ;; 10seg (.setIdleTimeout 120000) ;; 2min (.setMaxLifetime 1800000) ;; 30min - (.setMinimumIdle (:min-pool-size cfg 0)) + (.setMinimumIdle (:min-pool-size cfg 0)) (.setMaximumPoolSize (:max-pool-size cfg 50)) (.setConnectionInitSql initsql) (.setInitializationFailTimeout -1)) diff --git a/backend/src/app/main.clj b/backend/src/app/main.clj index 27e47fb0e..2264e96ba 100644 --- a/backend/src/app/main.clj +++ b/backend/src/app/main.clj @@ -21,7 +21,7 @@ :migrations (ig/ref :app.migrations/all) :name :main :min-pool-size 0 - :max-pool-size 30} + :max-pool-size 60} :app.migrations/migrations {}