Kong / kong

🦍 The Cloud-Native API Gateway and AI Gateway.
https://konghq.com/install/
Apache License 2.0
39.35k stars 4.82k forks source link

Kong spamming connect/disconnect to postgres #13800

Open morpig opened 3 weeks ago

morpig commented 3 weeks ago

Is there an existing issue for this?

Kong version ($ kong version)

3.6.1

Current Behavior

Running Kong DB-setup with postgres, and logs from pgbouncer shows tons of connect/disconnects by kong.

env as below:

  env:
    pg_database: kong
    pg_schema: public
    pg_ssl: on
    pg_pool_size: 2
    pg_keepalive_timeout: 300
    pg_max_concurrent_queries: 2
    pg_ro_max_concurrent_queries: 2
    pg_ro_pool_size: 2
    pg_ro_keepalive_timeout: 300
2024-10-29 01:09:00.452 UTC [551967] LOG C-0x55ee30a124b8: kong/kong@100.121.136.103:11925 login attempt: db=kong user=kong tls=TLSv1.3/TLS_AES_256_GCM_SHA384 replication=no
2024-10-29 01:09:00.467 UTC [551967] LOG C-0x55ee30a124b8: kong/kong@100.121.136.103:11925 closing because: client unexpected eof (age=0s)
2024-10-29 01:09:01.393 UTC [551967] LOG C-0x55ee30a124b8: kong/kong@100.93.232.96:37791 login attempt: db=kong user=kong tls=TLSv1.3/TLS_AES_256_GCM_SHA384 replication=no
2024-10-29 01:09:01.400 UTC [551967] LOG C-0x55ee30a124b8: kong/kong@100.93.232.96:37791 closing because: client close request (age=0s)
2024-10-29 01:09:03.352 UTC [551967] LOG C-0x55ee30a124b8: kong/kong@100.93.232.96:14789 login attempt: db=kong user=kong tls=TLSv1.3/TLS_AES_256_GCM_SHA384 replication=no
2024-10-29 01:09:03.501 UTC [551967] LOG C-0x55ee30be08f8: kong/kong@100.121.136.103:14101 login attempt: db=kong user=kong tls=TLSv1.3/TLS_AES_256_GCM_SHA384 replication=no
2024-10-29 01:09:03.660 UTC [551967] LOG C-0x55ee30a124b8: kong/kong@100.93.232.96:14789 closing because: client unexpected eof (age=0s)
2024-10-29 01:09:03.810 UTC [551967] LOG C-0x55ee30be08f8: kong/kong@100.121.136.103:14101 closing because: client unexpected eof (age=0s)
2024-10-29 01:09:03.981 UTC [551967] LOG C-0x55ee30be08f8: kong/kong@100.93.232.96:49950 login attempt: db=kong user=kong tls=TLSv1.3/TLS_AES_256_GCM_SHA384 replication=no
2024-10-29 01:09:03.998 UTC [551967] LOG C-0x55ee30be08f8: kong/kong@100.93.232.96:49950 closing because: client unexpected eof (age=0s)
2024-10-29 01:09:04.395 UTC [551967] LOG C-0x55ee30be08f8: kong/kong@100.110.89.98:3356 login attempt: db=kong user=kong tls=TLSv1.3/TLS_AES_256_GCM_SHA384 replication=no
2024-10-29 01:09:04.403 UTC [551967] LOG C-0x55ee30be08f8: kong/kong@100.110.89.98:3356 closing because: client close request (age=0s)
2024-10-29 01:09:04.699 UTC [551967] LOG C-0x55ee30be08f8: kong/kong@100.110.89.98:64474 login attempt: db=kong user=kong tls=TLSv1.3/TLS_AES_256_GCM_SHA384 replication=no
2024-10-29 01:09:05.023 UTC [551967] LOG C-0x55ee30be08f8: kong/kong@100.110.89.98:64474 closing because: client unexpected eof (age=0s)
2024-10-29 01:09:05.314 UTC [551967] LOG C-0x55ee30be08f8: kong/kong@100.110.89.98:36957 login attempt: db=kong user=kong tls=TLSv1.3/TLS_AES_256_GCM_SHA384 replication=no
2024-10-29 01:09:05.624 UTC [551967] LOG C-0x55ee30be08f8: kong/kong@100.110.89.98:36957 closing because: client unexpected eof (age=0s)
2024-10-29 01:09:05.630 UTC [551967] LOG C-0x55ee30be08f8: kong/kong@100.110.89.98:38684 login attempt: db=kong user=kong tls=TLSv1.3/TLS_AES_256_GCM_SHA384 replication=no
2024-10-29 01:09:05.647 UTC [551967] LOG C-0x55ee30be08f8: kong/kong@100.110.89.98:38684 closing because: client unexpected eof (age=0s)
2024-10-29 01:09:06.550 UTC [551967] LOG C-0x55ee30be08f8: kong/kong@100.93.232.96:18820 login attempt: db=kong user=kong tls=TLSv1.3/TLS_AES_256_GCM_SHA384 replication=no
2024-10-29 01:09:06.551 UTC [551967] LOG C-0x55ee30a124b8: kong/kong@100.93.232.96:10169 login attempt: db=kong user=kong tls=TLSv1.3/TLS_AES_256_GCM_SHA384 replication=no
2024-10-29 01:09:06.558 UTC [551967] LOG C-0x55ee30be08f8: kong/kong@100.93.232.96:18820 closing because: client close request (age=0s)
2024-10-29 01:09:06.558 UTC [551967] LOG C-0x55ee30a124b8: kong/kong@100.93.232.96:10169 closing because: client close request (age=0s)
2024-10-29 01:09:07.112 UTC [551967] LOG C-0x55ee30a124b8: kong/kong@100.110.89.98:47949 login attempt: db=kong user=kong tls=TLSv1.3/TLS_AES_256_GCM_SHA384 replication=no
2024-10-29 01:09:07.113 UTC [551967] LOG C-0x55ee30be08f8: kong/kong@100.110.89.98:10418 login attempt: db=kong user=kong tls=TLSv1.3/TLS_AES_256_GCM_SHA384 replication=no
2024-10-29 01:09:07.121 UTC [551967] LOG C-0x55ee30a124b8: kong/kong@100.110.89.98:47949 closing because: client close request (age=0s)
2024-10-29 01:09:07.122 UTC [551967] LOG C-0x55ee30be08f8: kong/kong@100.110.89.98:10418 closing because: client close request (age=0s)
2024-10-29 01:09:07.395 UTC [551967] LOG C-0x55ee30be08f8: kong/kong@100.110.89.98:16634 login attempt: db=kong user=kong tls=TLSv1.3/TLS_AES_256_GCM_SHA384 replication=no
2024-10-29 01:09:07.403 UTC [551967] LOG C-0x55ee30be08f8: kong/kong@100.110.89.98:16634 closing because: client close request (age=0s)
2024-10-29 01:09:07.680 UTC [551967] LOG C-0x55ee30be08f8: kong/kong@100.121.136.103:12127 login attempt: db=kong user=kong tls=TLSv1.3/TLS_AES_256_GCM_SHA384 replication=no
2024-10-29 01:09:07.681 UTC [551967] LOG C-0x55ee30a124b8: kong/kong@100.121.136.103:6576 login attempt: db=kong user=kong tls=TLSv1.3/TLS_AES_256_GCM_SHA384 replication=no
2024-10-29 01:09:07.685 UTC [551967] LOG C-0x55ee30be08f8: kong/kong@100.121.136.103:12127 closing because: client close request (age=0s)
2024-10-29 01:09:07.686 UTC [551967] LOG C-0x55ee30a124b8: kong/kong@100.121.136.103:6576 closing because: client close request (age=0s)

Expected Behavior

Expecting it to maintain persistent DB connection per worker/pods instead. Not expecting tons of connect/disconnect.

Steps To Reproduce

No response

Anything else?

No response

Oyami-Srk commented 3 weeks ago

AFAIK the connection for Postgres under Kong is managed by external libraries, and the problem is Postgres connection isn't reused. You can check https://github.com/Kong/kong/issues/1517 for details. Will this affect the concurrency of your deployment?

github-actions[bot] commented 1 week ago

This issue is marked as stale because it has been open for 14 days with no activity.

chobits commented 4 hours ago

AFAIK the connection for Postgres under Kong is managed by external libraries, and the problem is Postgres connection isn't reused. You can check #1517 for details. Will this affect the concurrency of your deployment?

hi @Oyami-Srk before the bot automatically closed this issue, could you file an internal ticket to track this. The problem may not be urgent and requires optimization, but it could be a meaningful improvement in the future.

Remember to filter and check if there are any similar internal issues already.