Skip to content

Commit 99c3e0c

Browse files
authored
[aiohttp] - lower connection pool value (#9935)
* [aiohttp] - lower connection pool value * [aiohttp] - reduce connection size to 2
1 parent 9e334c5 commit 99c3e0c

File tree

1 file changed

+5
-4
lines changed
  • frameworks/Python/aiohttp/app

1 file changed

+5
-4
lines changed

frameworks/Python/aiohttp/app/main.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,11 @@ def pg_dsn(dialect=None) -> str:
4949
async def db_ctx(app: web.Application):
5050
# number of gunicorn workers = multiprocessing.cpu_count() as per gunicorn_conf.py
5151
# max_connections = 2000 as per toolset/setup/linux/databases/postgresql/postgresql.conf:64
52-
# give 10% leeway
53-
max_size = min(1800 / multiprocessing.cpu_count(), 160)
54-
max_size = max(int(max_size), 1)
55-
min_size = max(int(max_size / 2), 1)
52+
# since the world table contains only 10,000 rows, a large connection pool is unnecessary
53+
# the server hardware provides 56 CPU cores producing high concurrency
54+
# https://wiki.postgresql.org/wiki/Number_Of_Database_Connections
55+
max_size = 2
56+
min_size = 2
5657
print(f'connection pool: min size: {min_size}, max size: {max_size}, orm: {CONNECTION_ORM}')
5758
if CONNECTION_ORM:
5859
dsn = pg_dsn('asyncpg')

0 commit comments

Comments
 (0)