Showing posts with label pgbouncer. Show all posts
Showing posts with label pgbouncer. Show all posts

Friday, March 26, 2010

HOWTO setup pgBouncer on Debian Part 1

When looking to provide database connections under a steady (or heavy) load, you will likely need to look into a database connection pooler. There are a number of good options for PostgreSQL such as pgBouncer, pgpool-II, SQL Relay, and a few others.
My personal favorite as of late is pgBouncer. Here's a few reasons why I like it:
  • a lightweight connection pooler--it is designed solely for pooling
  • low resource requirement
  • written with Python (a lot of our inernal apps use Python, so interoperability is great to have)
  • supports online restart/upgrade without dropping client connections
When setting up a pooler, you will want to have a separate server just for the pooler. Adding a pooler to the same server as the database only degrades the performance of PostgreSQL, so make sure you don't.

I use Debian as my choice of Linux distro. Unfortunately, there isn't an official package to install on Lenny. However, thanks to good ol' backports, we can find an up-to-date package. First things first, add backports to your /etc/apt/sources.list by adding the following source:
deb http://www.backports.org/debian lenny-backports main contrib non-free

Next, you will want to do aptitude update (or apt-get update)

You can learn more about how to use backports on their instructions page.

Finally, here's how to do an install of pgBouncer:
$ aptitude -t lenny_backports install pgbouncer

Saturday, March 6, 2010

PGBouncer or PGPool II? That is the question!

We have been trying out both PgBouncer and pgpool II for connection pooling in front of our Postgresql database servers. One of the issues we are trying to tackle is how to make PgBouncer HA (High Availability) and if it matters.
pgpool II already has the ability to be HA using pgpool-HA, but pgpool is also a more featureful application that does much more than simple connection pooling.
On the other hand, PgBouncer is a nice, lightweight connection pooler that we have found to fit the bill rather well. Our question is, if we have auto-failover set up in our private cloud for PgBouncer, is there a need to be HA? What would need to be done? If we forgo making the pooler HA, what risks do we pose?
All these and other questions are going through my head. Any suggestions?

Thursday, March 4, 2010

PGBouncer and Database Updates

I have been using pgBouncer for a while and have run into a need in our development server to drop and recreate a database. I have had issues in the past with trying to PAUSE, but that ends up stopping all connections, which isn't always a feasible option. I have found that simply commenting out the database in question in the pgbouncer.ini file and simply doing a RELOAD. This will also kill any clients currently connected to that database and allow you to drop/recreate. After making changes, simply uncomment and RELOAD again.