develooper Front page | perl.dbi.users | Postings from January 2007

Re: Recommended load balancing solutions (especially with PostgreSQL)?

Thread Previous | Thread Next
From:
Henri Asseily
Date:
January 8, 2007 10:03
Subject:
Re: Recommended load balancing solutions (especially with PostgreSQL)?
Message ID:
C23BE6B6-BE65-4230-91A4-0FFDBD8A2989@shopzilla.com

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


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About