PgBouncer doubts

From: Christian Jauvin <cjauvin(at)gmail(dot)com>
To: psycopg(at)postgresql(dot)org
Subject: PgBouncer doubts
Date: 2014-06-10 14:37:28
Message-ID: CAJSE4TrV8CJmMU9ms7v8xcgY1+R_UMgNyJhv18c1_qssBxah6w@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: psycopg

Hi,

I'm trying PgBouncer for the first time with a simple Python web
application (Flask + psycopg2), and I have a hard time interpreting
the meaning of its log messages by simple googling. I'm basically
seeing a bunch of:

2014-06-09 09:25:07.867 20980 LOG C-0x1b1b240: vinum/vinum(at)unix:6432
login attempt: db=vinum user=vinum
2014-06-09 09:25:07.867 20980 LOG S-0x1b38bf0:
vinum/vinum(at)127(dot)0(dot)0(dot)1:5432 new connection to server
2014-06-09 09:25:07.875 20980 LOG C-0x1b1b240: vinum/vinum(at)unix:6432
closing because: client close request (age=0)
2014-06-09 09:25:15.626 20980 LOG C-0x1b1b240: vinum/vinum(at)unix:6432
login attempt: db=vinum user=vinum
2014-06-09 09:25:16.058 20980 LOG C-0x1b1b240: vinum/vinum(at)unix:6432
closing because: client close request (age=0)
2014-06-09 09:25:16.762 20980 LOG C-0x1b1b240: vinum/vinum(at)unix:6432
login attempt: db=vinum user=vinum
2014-06-09 09:25:16.796 20980 LOG C-0x1b1b3a8: vinum/vinum(at)unix:6432
login attempt: db=vinum user=vinum
2014-06-09 09:25:16.796 20980 LOG S-0x1b38d58:
vinum/vinum(at)127(dot)0(dot)0(dot)1:5432 new connection to server
2014-06-09 09:25:17.181 20980 LOG C-0x1b1b240: vinum/vinum(at)unix:6432
closing because: client close request (age=0)
2014-06-09 09:25:17.240 20980 LOG C-0x1b1b3a8: vinum/vinum(at)unix:6432
closing because: client close request (age=0)

I find these multiple closings with "age=0" worrying, do they mean
that the connections are always recreated, thus never pooled?

My Flask/psycopg2 connection handling code is super simple:

@app.before_request
def before_request():
rdc = psycopg2.extras.RealDictConnection
g.db = psycopg2.connect("dbname=%s user=%s port=%s" %
(app.config['DATABASE_NAME'],
app.config['DATABASE_USER'],
app.config['PGBOUNCER_PORT']),
connection_factory=rdc)

@app.teardown_request
def teardown_request(exception):
if hasattr(g, 'db'):
g.db.close()

I'd greatly appreciate any explanation or guidance about this

Christian

Responses

Browse psycopg by date

  From Date Subject
Next Message Adrian Klaver 2014-06-11 14:14:39 Re: PgBouncer doubts
Previous Message jared 2014-05-20 17:44:49 Re: psycopg : web service