On Jan 11, 2007, at 3:18 PM, Mark Stosberg wrote:

Ofer Nave wrote:

Couldn't an option be added as an alternative to db_stack that indicates a desire for random ordering, thereby eliminating the need to precreate
all possible permutations?  I'm imaging something like this (modified
version of your example):

$DATABASE::conf{'test'} = {
  max_retries => 2,
  db_pool => [
[ 'dbi:Sybase:server=prod1;database=test', 'user1', 'pass1', $attrib ], [ 'dbi:Sybase:server=prod2;database=test', 'user2', 'pass2', $attrib ], [ 'dbi:Sybase:server=prod3;database=test', 'user3', 'pass3', $attrib ],
  ], ...

So, db_stack maintains ordering, while db_pool tells DBIx::HA to
randomize the list of servers.

I like the idea of having this feature built-in, but I think the name
could clearer, perhaps call it "load balance":

$DATABASE::conf{'test'} = {
   load_balance => 1,
   db_stack => [
[ 'dbi:Sybase:server=prod1;database=test','user1','pass1', $attrib ], [ 'dbi:Sybase:server=prod2;database=test','user2','pass2', $attrib ],
   ], ...

The problem is that there are too many ways to load balance, which gets even more confusing when you use presistent connections such as those in mod_perl. Unless you have a large number of client processes compared the the servers, when you use persistent connections you're rarely going to be happily load balancing in a way that is equitable. Certain algorithms are better for certain situations such as a lower ratio of clients to servers, for example. And since the developer knows her systems better than I do, let her write a proper balancing routine for her needs. The trivial ones are unnecessary for me to include since they're trivial, and the more advanced ones are too specific to a situation for the general public (i.e. probably the 3 people using this module) to care about...

As an interesting exercise, I'd be curious to see if you and Ofer can agree on a load balancing routine to use. :-)

H

Reply via email to