Groups
Conversations
All groups and messages
Send feedback to Google
Help
Sign in
Groups
django-ja
Conversations
About
DBの接続数がとても多くなってしまう。
481 views
Skip to first unread message
白井一真
unread,
Mar 1, 2020, 9:34:16 PM
3/1/20
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Link
Report message as abuse
Sign in to report message as abuse
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to django-ja
Django(2.1.5)とPostgre(9.6 Azure)を利用しているのですが、
Postgre側のActive Connections数がとても多くなってしまい困っております。(60~80程度に張り付いています。)
DjangoでModelを利用して接続しているのが原因でないかと思っていますが、解決方法が分かりません。(DBとのconnectionを明示的に切る必要がある?)
お知恵をお借りしたいです。
settings内のDBの設定情報は以下となっております。
DATABASES
=
{
'default'
: {
'ENGINE'
:
'django.db.backends.postgresql_psycopg2'
,
'NAME'
:
''
,
'USER'
:
'(admin)'
,
'PASSWORD'
:
'(admin)'
,
'HOST'
:
'
sample.postgres.database.azure.com
'
,
'PORT'
:
'5432'
,
'CONN_MAX_AGE'
:
0
,
}
}
tokibito
unread,
Mar 2, 2020, 9:48:07 AM
3/2/20
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Link
Report message as abuse
Sign in to report message as abuse
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to django-ja
アプリケーションサーバーのスレッド数やプロセス数はどうなっていますか?
Djangoが標準で提供するデータベースバックエンドは、1スレッドあたり1コネクションになります。
また、コネクションプールも無いです。コネクションプールを利用する場合は、PgBouncerを挟むなどの検討が必要かもしれません。
Web検索したところ、DjangoとPostgreSQLのコネクションについて記事を書いてる方がいたので、参考になるかもしれません。
https://www.monotalk.xyz/blog/django-%E3%81%AE-connection-pooling-%E3%81%AB%E3%81%A4%E3%81%84%E3%81%A6-%E8%AA%BF%E3%81%B9%E3%81%A6%E3%81%BF%E3%81%BE%E3%81%97%E3%81%9F/
2020年3月2日月曜日 11時34分16秒 UTC+9 白井一真:
Reply all
Reply to author
Forward
0 new messages