Welcome! Log In Create A New Profile

Advanced

balance uri archaic options

Posted by Sameh Ghane 
Sameh Ghane
balance uri archaic options
April 02, 2012 06:30PM
Hello,

I am a new happy haproxy user.

Unfortunately, despite the powerful configuration system and regular expressions
support, the "balance uri" directive is still using a very rigid way of splitting
a URI (length from start + splitting on slash only) to feed it to the hashing engine.

Is there anything I missed ? Like setting a specific request header which would
be the result of a regexp on the URI, and balancing on that header ? Would that
work ?

Cheers,

--
Sameh Ghane
Jonathan Matthews
Re: balance uri archaic options
April 02, 2012 07:40PM
On 2 April 2012 17:25, Sameh Ghane <[email protected]> wrote:
>
> Is there anything I missed ? Like setting a specific request header which would
> be the result of a regexp on the URI, and balancing on that header ?

I don't understand what you've written. Could you say it again, but differently?
Some examples would probably help too.

Jonathan
Sameh Ghane
Re: balance uri archaic options
April 02, 2012 08:30PM
Le (On) Mon, Apr 02, 2012 at 06:32:31PM +0100, Jonathan Matthews ecrivit (wrote):
> On 2 April 2012 17:25, Sameh Ghane <[email protected]> wrote:
> >
> > Is there anything I missed ? Like setting a specific request header which would
> > be the result of a regexp on the URI, and balancing on that header ?
>
> I don't understand what you've written. Could you say it again, but differently?
> Some examples would probably help too.

Sorry for this.

Imagine I see requests for /xxxxx/yyyyyy.zzzzz and I would like to balance
according to the URI, though I don't want the "yyyyy" part to be fed to the hash
function. As far as I understand, it cannot be done with 'balance uri'.

That's why I would like to know if it can be circumvented through something
like:

backend be
...
reqadd balhdr:\ xxx
balance hdr(balhdr)
...


Cheers,

--
Sameh Ghane
Jonathan Matthews
Re: balance uri archaic options
April 03, 2012 12:50AM
On 2 April 2012 19:28, Sameh Ghane <[email protected]> wrote:
> Le (On) Mon, Apr 02, 2012 at 06:32:31PM +0100, Jonathan Matthews ecrivit (wrote):
>> On 2 April 2012 17:25, Sameh Ghane <[email protected]> wrote:
>> >
>> > Is there anything I missed ? Like setting a specific request header which would
>> > be the result of a regexp on the URI, and balancing on that header ?
>>
>> I don't understand what you've written. Could you say it again, but differently?
>> Some examples would probably help too.
>
> Sorry for this.
>
> Imagine I see requests for /xxxxx/yyyyyy.zzzzz and I would like to balance
> according to the URI, though I don't want the "yyyyy" part to be fed to the hash
> function. As far as I understand, it cannot be done with 'balance uri'.

Not simply, no, I don't believe so.

> That's why I would like to know if it can be circumvented through something
> like:
>
> backend be
> ..
> reqadd  balhdr:\ xxx
> balance hdr(balhdr)
> ..

I don't understand what you're trying to express there. You can
definitely balance according to any header you like, but I guess
you're trying to hack something in there with "balance hdr". I just
don't quite understand what it is.

Regardless of my miscomprehension, there's probably some way to
achieve what you want that others on list can help you with. Probably
some hacky combination of "reqrep" and some other req* commands. I
must admit I can't visualise the point you're trying to end up at,
given that your design *has* to be able to cope with back-end servers
going down, hence the balancing strategy can only really be an aid to
performance and not an immutable part of the correctness of the
solution.

All the best,
Jonathan
--
Jonathan Matthews
London, Oxford, UK
http://www.jpluscplusm.com/contact.html
Baptiste
Re: balance uri archaic options
April 03, 2012 07:50AM
Hi,

May I ask you why you want absolutely not hash this part?
I clearly don't understand, and I don't see any disadvantage of
hashing a full URI.

Maybe passing the argument you want to hash in the query string, then
use the balance param algorithm may help.

cheers


On Mon, Apr 2, 2012 at 8:28 PM, Sameh Ghane <[email protected]> wrote:
> Le (On) Mon, Apr 02, 2012 at 06:32:31PM +0100, Jonathan Matthews ecrivit (wrote):
>> On 2 April 2012 17:25, Sameh Ghane <[email protected]> wrote:
>> >
>> > Is there anything I missed ? Like setting a specific request header which would
>> > be the result of a regexp on the URI, and balancing on that header ?
>>
>> I don't understand what you've written. Could you say it again, but differently?
>> Some examples would probably help too.
>
> Sorry for this.
>
> Imagine I see requests for /xxxxx/yyyyyy.zzzzz and I would like to balance
> according to the URI, though I don't want the "yyyyy" part to be fed to the hash
> function. As far as I understand, it cannot be done with 'balance uri'.
>
> That's why I would like to know if it can be circumvented through something
> like:
>
> backend be
> ..
> reqadd  balhdr:\ xxx
> balance hdr(balhdr)
> ..
>
>
> Cheers,
>
> --
> Sameh Ghane
>
Sameh Ghane
Re: balance uri archaic options
April 03, 2012 01:30PM
Le (On) Tue, Apr 03, 2012 at 07:45:03AM +0200, Baptiste ecrivit (wrote):
> Hi,
>
> May I ask you why you want absolutely not hash this part?
> I clearly don't understand, and I don't see any disadvantage of
> hashing a full URI.

The full URI includes informations (like a key for instance) that shouldn't be
hashed since I want to maintain a specific cache affinity based on a certain
part of the URI.

I understand this is not possible to do easily, and I just find it weird since
haproxy is full of powerful regexps, but that's fine, I can hash according to
the first 3 characters of the URI, it's just not elegant.

Cheers,

> On Mon, Apr 2, 2012 at 8:28 PM, Sameh Ghane <[email protected]> wrote:
> > Le (On) Mon, Apr 02, 2012 at 06:32:31PM +0100, Jonathan Matthews ecrivit (wrote):
> >> On 2 April 2012 17:25, Sameh Ghane <[email protected]> wrote:
> >> >
> >> > Is there anything I missed ? Like setting a specific request header which would
> >> > be the result of a regexp on the URI, and balancing on that header ?
> >>
> >> I don't understand what you've written. Could you say it again, but differently?
> >> Some examples would probably help too.
> >
> > Sorry for this.
> >
> > Imagine I see requests for /xxxxx/yyyyyy.zzzzz and I would like to balance
> > according to the URI, though I don't want the "yyyyy" part to be fed to the hash
> > function. As far as I understand, it cannot be done with 'balance uri'.
> >
> > That's why I would like to know if it can be circumvented through something
> > like:
> >
> > backend be
> > ..
> > reqadd  balhdr:\ xxx
> > balance hdr(balhdr)
> > ..
> >
> >
> > Cheers,
> >
> > --
> > Sameh Ghane
> >

--
Sameh Ghane
Sorry, only registered users may post in this forum.

Click here to login