]> git.ipfire.org Git - pbs.git/commitdiff
database: Don't keep so many connections open and idle
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 18 Aug 2023 09:51:10 +0000 (09:51 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 18 Aug 2023 09:51:10 +0000 (09:51 +0000)
Since we usually peak briefly, we will fork a lot of PostgreSQL
processes that we will never need again. In order to avoid wasting too
much memory, we close those connections quicker, but at least 8 open so
that new tasks will quickly be able to acquire a database connection.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/buildservice/database.py

index a6fda988565c4e29fbde084346ec2cf4b4ab8785..4aab4ff8352dba2312d8d9e74aa02be3d7994cbd 100644 (file)
@@ -51,14 +51,14 @@ class Connection(object):
                        configure=self.__configure,
 
                        # Set limits for min/max connections in the pool
-                       min_size=4,
+                       min_size=8,
                        max_size=128,
 
                        # Give clients up to one minute to retrieve a connection
                        timeout=60,
 
-                       # Close connections after they have been idle for one minute
-                       max_idle=60,
+                       # Close connections after they have been idle for 15 seconds
+                       max_idle=15,
                )
 
        def __configure(self, conn):