postgresql 超出限制 最大连接数 Postgres
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21014765/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Limit exceeded Max connections Postgres
提问by himalayanZephyr
I am running a website running on Django,Postgres and Apache.
我正在运行一个在 Django、Postgres 和 Apache 上运行的网站。
Recently, due to sudden surge in traffic the site came down. On checking server logs i came to know that there was some issue of maximum connections limit exceeded. On looking up more i found out that in postgresql.conf , the parameter max_connections
affects the simultaneous connections, that can be made at any point of time, to the DB.
最近,由于流量突然激增,该网站出现了故障。在检查服务器日志时,我知道存在超出最大连接限制的问题。在查找更多信息时,我发现在 postgresql.conf 中,该参数max_connections
影响到数据库的同时连接,可以在任何时间点进行。
The current value in my postgresql.conf is 100.
我的 postgresql.conf 中的当前值为 100。
The event that happened and brought site down is not a commonly occuring event but i want to be prepared the next time it happens again.
发生并导致站点关闭的事件不是常见事件,但我想在下次再次发生时做好准备。
So i am seeking advice for how can i monitor the active connections at any moment on a regular day and to how much i should increase the value of max connections and what other parameters need to be changed parallely as i was seeing that i have to increase other values in postgresql.conf accordingly(like shared buffers etc).
因此,我正在寻求建议,以了解如何在常规日期的任何时候监控活动连接以及我应该增加多少最大连接的值以及需要并行更改哪些其他参数,因为我看到我必须增加postgresql.conf 中的其他值相应地(如共享缓冲区等)。
回答by Craig Ringer
Please take a look at the relevant wiki article: http://wiki.postgresql.org/wiki/Number_Of_Database_Connections
请看一下相关的维基文章:http: //wiki.postgresql.org/wiki/Number_Of_Database_Connections
In general it's best not to bump max_connections
up too much. Use a connection pool like PgBouncer, or a pool inside your server, instead.
一般来说,最好不要颠簸max_connections
太多。改用像 PgBouncer 这样的连接池,或服务器内部的池。