我在我的Django網絡應用程序中使用pgbouncer
。應用程序服務器和數據庫服務器是兩個獨立的VM。 pgbouncer
安裝在應用程序服務器上。在pgbouncer.ini
相關的設置是:解釋django項目中的pgbouncer日誌條目
[databases]
dbname = host=80.211.128.113 port=5432 dbname=dbname
pool_mode = transaction
max_client_conn = 250
default_pool_size = 100
一旦pgbouncer接手,我查pgbouncer.log
,發現許多條目如下:
2016-11-15 12:26:27.514 582 LOG S-0x1192740: dbname/[email protected]:5432 new connection to server
2016-11-15 12:26:27.517 582 LOG C-0x11afcb8: dbname/[email protected]:42262 login attempt: db=dbname user=myuser
2016-11-15 12:26:27.523 582 LOG S-0x1192a10: dbname/[email protected]:5432 new connection to server
2016-11-15 12:26:27.528 582 LOG C-0x11af880: dbname/[email protected]:42250 closing because: client close request (age=0)
2016-11-15 12:26:27.528 582 LOG S-0x1191a98: dbname/[email protected]:5432 closing because: unclean server (age=0)
2016-11-15 12:26:27.548 582 LOG C-0x11afb50: dbname/[email protected]:42258 closing because: client close request (age=0)
2016-11-15 12:26:27.556 582 LOG C-0x11aff88: dbname/[email protected]:42256 closing because: client close request (age=0)
2016-11-15 12:26:27.556 582 LOG S-0x1191c00: dbname/[email protected]:5432 closing because: unclean server (age=0)
2016-11-15 12:26:27.564 582 LOG C-0x11aff88: dbname/[email protected]:42264 login attempt: db=dbname user=myuser
2016-11-15 12:26:27.569 582 LOG C-0x11afb50: dbname/[email protected]:42265 login attempt: db=dbname user=myuser
2016-11-15 12:26:27.570 582 LOG S-0x1191c00: dbname/[email protected]:5432 new connection to server
2016-11-15 12:26:27.593 582 LOG C-0x11af448: dbname/[email protected]:42255 closing because: client close request (age=0)
2016-11-15 12:26:27.593 582 LOG C-0x11afcb8: dbname/[email protected]:42262 closing because: client close request (age=0)
2016-11-15 12:26:27.593 582 LOG S-0x1191c00: dbname/[email protected]:5432 closing because: unclean server (age=0)
2016-11-15 12:26:27.597 582 LOG C-0x11afb50: dbname/[email protected]:42265 closing because: client close request (age=0)
2016-11-15 12:26:27.603 582 LOG C-0x11afb50: dbname/[email protected]:42267 login attempt: db=dbname user=myuser
2016-11-15 12:26:27.604 582 LOG C-0x11afcb8: dbname/[email protected]:42268 login attempt: db=dbname user=myuser
如果仔細分析的closing because: unclean server
和closing because: client close request
許多實例中發現日誌文件。任何人都可以解釋這些是什麼?也許我做錯了什麼。表面上看,我的應用程序似乎到目前爲止運行正常。但我需要了解我在日誌文件中看到的內容,因此我可以確定是什麼。提前致謝。
感謝您的深度響應。我的日誌條目中超過95%的客戶端關閉請求的「age = 0」。你認爲這是正常的嗎? –
嗯,pgbouncer在任何地方記錄日誌都是完整的,如上所述,它會在每次登錄嘗試(一個連接到pgbouncer的客戶端)之後出現。 –