On Jan 5, 2007, at 2:52 PM, Tim Bunce wrote: > On Thu, Jan 04, 2007 at 02:54:37PM -0500, Mark Stosberg wrote: >> >> Hello, >> >> Today I've been researching database load balancing solutions to use >> with an Apache/mod_perl application and a PostgreSQL database. >> Right now >> I'm using Slony-I for replication, and it seems to work well enough. > >> ##### >> >> What's beginning to appeal to me know is to solve part load >> balancing in >> the application by using two database handles: a read/write one, >> and a >> read-only one. From there, it's much easier problem to solve: The R/w >> handle always talks to the master and the Read-only handle can be >> load >> balanced without being so "smart". > [...] >> >> - DBD::Multi looks like it could handle this kind of simple load >> balancing. As a bonus, it has some fail-over logic in it, so if the >> slave was unvailable for a bit, that would be handled transparently. >> >> Does that seem sound? What's worked for you? > > Also take a look at DBIx::HA. DBIx::HA takes advantage of the "swap_inner_handle" feature of DBI: Let's say an app sets up a $dbh through DBIx::HA which subclasses DBI. If the database fails, DBIx::HA can do a number of things (retry, fail to another db in the stack). The beauty of swap_inner_handle is that DBIx::HA can see that the database is dead, create a new dbh to another db server, swap the original $dbh with the new one and redo the prepare/execute statement while the calling application is comfortably awaiting a response to its execute statement. The app won't know that anything out of the ordinary happened. I don't know if I uploaded the latest version of DBIx::HA to CPAN, I'll do it asap. Henri.Thread Previous | Thread Next