Front page | perl.dbi.users |
Postings from January 2007
Re: Recommended load balancing solutions?
Thread Previous
|
Thread Next
From:
Ofer Nave
Date:
January 11, 2007 18:16
Subject:
Re: Recommended load balancing solutions?
Message ID:
20070111170251.16621.qmail@lists.develooper.com
Peter J. Holzer wrote:
> On 2007-01-10 15:06:56 -0800, Ofer Nave wrote:
>> Henri Asseily wrote:
>>> Take the example of the pod:
>>> $DATABASE::conf{'test'} = {
>>> max_retries => 2,
>>> db_stack => [
>>> [ '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 ],
>>> ], ...
> [...]
>>> Here's a complex example:
>>> In the case above, say you have 20 children for those 3 databases.
>>> The different stack permutations are:
>>> 1: prod1,prod2,prod3
>>> 2: prod1,prod3,prod2
>>> 3: prod2,prod1,prod3
>>> 4: prod2,prod3,prod1
>>> 5: prod3,prod1,prod2
>>> 6: prod3,prod2,prod1
>>> Either dynamically or statically create these 6 permutations and put them in
>>> @all_db_stacks:
> [...]
>> 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 ],
>> ], ...
>
> How about just using shuffle from the standard module List::Util?
>
> use List::Util qw(shuffle);
>
> $DATABASE::conf{'test'} = {
> max_retries => 2,
> db_stack => [
> shuffle (
> [ '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 ],
> )
> ], ...
>
> hp
>
I like it!
-ofer
Thread Previous
|
Thread Next