postgres 连接数超过 max_connections?

发布于 2024-09-18 08:22:31 字数 292 浏览 7 评论 0原文

我们正在运行一个连接量很大、插入量很大的 postgres 数据库(我们应该做一些连接池,但现在没有时间)。

在进行一些故障排除时,我使用 netstat 来显示有多少个与 postgres 的连接。我通常会看到比我在 postgres.conf 文件中指定的更多的内容(通过 max_connections)。

即使我将 max_connections 设置为 1000,我也会通过 netstat 看到 1400-1600 个连接。

有人知道发生了什么吗?这究竟是怎么发生的?

任何对此的见解都会很棒。

we are running a very connection-heavy, insert-heavy postgres database (to the point that we should've done some connection pooling, but there's no time now).

when doing some troubleshooting, i was using netstat to show me how many connections there were to postgres. i would commonly see more than what i had specified in the postgres.conf file (via max_connections).

i would see 1400-1600 connections via netstat even though i had max_connections set to 1000.

anyone have any clue what is going on? how exactly can this happen?

any insight on this would be great.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

清欢 2024-09-25 08:22:31

这些连接有可能已经关闭了吗?例如,Windows 不会立即关闭连接,但会将其状态更改为“TIME_WAITING”。

因此,连接显示在 netsat 中,但实际上已关闭。

只有那些显示为“ESTABLISHED”的连接才是“实时”连接。

顺便说一句:您可以简单地在 PostgreSQL 服务器前面放置一个连接池,而无需更改您的应用程序,pgPool(或 pgBouncer)将假装它们是应用程序的真正 PostgreSQL 服务器,并“在其背后”进行池化。

Is it possible that those connections were already closed? Windows for example doesn't immediately close the connection, but it changes it state to "TIME_WAITING.

So the connections show up in netsat but are actually closed.

Only those that show up as "ESTABLISHED" are "live" connections.

Btw: you can simply put a connection pooler in front of your PostgreSQL server without changing your application. pgPool (or pgBouncer) will pretend they are a real PostgreSQL server to the application and will do the pooling "behind its back"

忆悲凉 2024-09-25 08:22:31

使用连接池。超过 1000 个连接将显着降低数据库速度,即使对于 1000 个连接,您也需要一些具有大量内核和 RAM 的 $$$$$ 硬件。使用连接池效率更高。

Use a connectionpool. More than a 1000 connections will slow down the database significantly and even for a 1000 connections you need some $$$$$ hardware with a lot of cores and RAM. Using a connectionpool is much more efficient.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文