PgBouncer doubts

Поиск
Список
Период
Сортировка
От Christian Jauvin
Тема PgBouncer doubts
Дата
Msg-id CAJSE4TrV8CJmMU9ms7v8xcgY1+R_UMgNyJhv18c1_qssBxah6w@mail.gmail.com
обсуждение исходный текст
Ответы Re: PgBouncer doubts  (Adrian Klaver <adrian.klaver@aklaver.com>)
Список 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@unix:6432
login attempt: db=vinum user=vinum
2014-06-09 09:25:07.867 20980 LOG S-0x1b38bf0:
vinum/vinum@127.0.0.1:5432 new connection to server
2014-06-09 09:25:07.875 20980 LOG C-0x1b1b240: vinum/vinum@unix:6432
closing because: client close request (age=0)
2014-06-09 09:25:15.626 20980 LOG C-0x1b1b240: vinum/vinum@unix:6432
login attempt: db=vinum user=vinum
2014-06-09 09:25:16.058 20980 LOG C-0x1b1b240: vinum/vinum@unix:6432
closing because: client close request (age=0)
2014-06-09 09:25:16.762 20980 LOG C-0x1b1b240: vinum/vinum@unix:6432
login attempt: db=vinum user=vinum
2014-06-09 09:25:16.796 20980 LOG C-0x1b1b3a8: vinum/vinum@unix:6432
login attempt: db=vinum user=vinum
2014-06-09 09:25:16.796 20980 LOG S-0x1b38d58:
vinum/vinum@127.0.0.1:5432 new connection to server
2014-06-09 09:25:17.181 20980 LOG C-0x1b1b240: vinum/vinum@unix:6432
closing because: client close request (age=0)
2014-06-09 09:25:17.240 20980 LOG C-0x1b1b3a8: vinum/vinum@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


В списке psycopg по дате отправления:

Предыдущее
От: jared
Дата:
Сообщение: Re: psycopg : web service
Следующее
От: Adrian Klaver
Дата:
Сообщение: Re: PgBouncer doubts