PostgreSQLのパフォーマンスの問題をどのように診断しますか?
Ubuntu 12でデータベースバックエンドとしてPostgreSQLを使用しているDjangoベースのWebアプリがありますが、負荷が高いとデータベースが消えてしまい、Djangoインターフェイスにアクセスできなくなり、次のようなエラーが発生します。
django.db.utils.DatabaseError: error with no message from the libpq
django.db.utils.DatabaseError: server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
奇妙なことに、/ var / log/postgresqlのログには異常なことは何も表示されません。ログ/var/log/postgresql/postgresql-9.1-main.logに表示されるのは、次のような多くの行だけです。
2012-09-01 12:24:01 EDT LOG: unexpected EOF on client connection
実行中は、PostgreSQLがまだ実行中top
であることを示していても、PostgreSQLがCPUを消費していないように見えることをservice postgresql status
示しています。
'service postgresql restart`を実行すると一時的に問題が修正されますが、データベースに多くの負荷がかかるとすぐに問題が再発します。
dmesgとsyslogを確認しましたが、何が問題なのかを説明するものは何も見つかりません。他にどのようなログを確認する必要がありますか?PostgreSQLサーバーの何が問題になっているのかを判断するにはどうすればよいですか?
編集:私のmax_connectionsは100に設定されています。私は多くの手動トランザクションを行っていますが。手動モードのPostgreSQLでのDjangoのORM動作を読むと、明示的にconnection.close()を実行する必要があるようですが、これは実行していません。