Welcome! Log In Create A New Profile

Advanced

server templates

Posted by Frederic Lecaille 
Frederic Lecaille
server templates
April 07, 2017 03:10PM
Hello Haproxy ML,

Here are patches attached to this mail to add "server templates" feature
to haproxy.

The two first patches consist in moving code to be reused both during
'server' lines parsing and during and server templates initializations.
A new CLI command has also been added (see "init server-templates backend).

Third patch adds server_templates_init() function to be called to
initialize server templates attached to a proxy server list.

The remaining patch adds support for 'server-templates' configuration
file new keyword and updates the documentation.

Feel free to review/test/comment upon these patches. Any suggestion, are
welcome.

Regards,

Fred.
Aleksandar Lazic
Re: server templates
April 08, 2017 01:40AM
Hi Frederic

Am 07-04-2017 15:00, schrieb Frederic Lecaille:
> Hello Haproxy ML,
>
> Here are patches attached to this mail to add "server templates"
> feature to haproxy.

Please can you explain a little bit more the use case, thanks.
I'm sure there is a valid use case but I don't understand it.

> The two first patches consist in moving code to be reused both during
> 'server' lines parsing and during and server templates
> initializations.
>
> A new CLI command has also been added (see "init server-templates
> backend).

This remind me that haproxy should have a 'save_config()' function.
When something is changed ad runtime it should be saved for the next
restart/reload of haproxy.

> Third patch adds server_templates_init() function to be called to
> initialize server templates attached to a proxy server list.
>
> The remaining patch adds support for 'server-templates' configuration
> file new keyword and updates the documentation.
>
> Feel free to review/test/comment upon these patches. Any suggestion,
> are welcome.
>
> Regards,
>
> Fred.

Regards
Aleks
Frederic Lecaille
Re: server templates
April 10, 2017 10:10AM
On 04/08/2017 01:27 AM, Aleksandar Lazic wrote:
> Hi Frederic

Hi Aleksandar,

> Am 07-04-2017 15:00, schrieb Frederic Lecaille:
>> Hello Haproxy ML,
>>
>> Here are patches attached to this mail to add "server templates"
>> feature to haproxy.
>
> Please can you explain a little bit more the use case, thanks.
> I'm sure there is a valid use case but I don't understand it.

haproxy allocates as much as possible everything required before
starting doing its job. This is the case for 'server' objects. A static
predefined list of servers, written in configuration files, is
potentially allocated for each backend during configuration files parsing.

With server templates, haproxy could preallocate 'server' objects which
would derive from 'default-server' (with same settings as default server
settings), but with remaining parameters which are unknown at parsing
time (for instance their names, addresses, anything else). In fact here,
names or addresses are particular settings: a default server has not any
default name or default address.

With server templates, haproxy would not have to allocate any 'server'
after having parsed its configuration files. It could use an already
allocated server template and set its remaining settings which were
unknown at configuration files parsing time.

This may be useful to instantiate servers which are discovered after
having parsed any configuration files.

>> The two first patches consist in moving code to be reused both during
>> 'server' lines parsing and during and server templates
>> initializations.
>>
>> A new CLI command has also been added (see "init server-templates
>> backend).


I think this is a more general request which could be discussed in
another thread. From my point of view, regarding server templates, as
they are more dynamic than 'server's, they are not supposed to be saved,
because potentially different between two different haproxy runs.


Regards,

Fred.
Willy Tarreau
Re: server templates
April 10, 2017 02:40PM
On Mon, Apr 10, 2017 at 10:02:29AM +0200, Frederic Lecaille wrote:
> With server templates, haproxy could preallocate 'server' objects which
> would derive from 'default-server' (with same settings as default server
> settings), but with remaining parameters which are unknown at parsing time
> (for instance their names, addresses, anything else). In fact here, names or
> addresses are particular settings: a default server has not any default name
> or default address.

Absolutely. And this combined with the recent features of dynamic consistent
cookies and with Baptiste's upcoming DNS patches will easily result in pretty
dynamic backends!

Willy
Baptiste
Re: server templates
April 10, 2017 05:10PM
On Mon, Apr 10, 2017 at 2:30 PM, Willy Tarreau <[email protected]> wrote:

> On Mon, Apr 10, 2017 at 10:02:29AM +0200, Frederic Lecaille wrote:
> > With server templates, haproxy could preallocate 'server' objects which
> > would derive from 'default-server' (with same settings as default server
> > settings), but with remaining parameters which are unknown at parsing
> time
> > (for instance their names, addresses, anything else). In fact here,
> names or
> > addresses are particular settings: a default server has not any default
> name
> > or default address.
>
> Absolutely. And this combined with the recent features of dynamic
> consistent
> cookies and with Baptiste's upcoming DNS patches will easily result in
> pretty
> dynamic backends!
>
> Willy
>
>
I just had a look at the implementation of server-templates. To make it
work with DNS resolution, we need to find a way to provide a fqdn to the
default-server directive. This might not be too complicated.
After this, the magic will happen!!!!

Great work Frederic :)

Baptiste
Willy Tarreau
Re: server templates
April 10, 2017 08:30PM
On Mon, Apr 10, 2017 at 05:00:14PM +0200, Baptiste wrote:
> On Mon, Apr 10, 2017 at 2:30 PM, Willy Tarreau <[email protected]> wrote:
>
> > On Mon, Apr 10, 2017 at 10:02:29AM +0200, Frederic Lecaille wrote:
> > > With server templates, haproxy could preallocate 'server' objects which
> > > would derive from 'default-server' (with same settings as default server
> > > settings), but with remaining parameters which are unknown at parsing
> > time
> > > (for instance their names, addresses, anything else). In fact here,
> > names or
> > > addresses are particular settings: a default server has not any default
> > name
> > > or default address.
> >
> > Absolutely. And this combined with the recent features of dynamic
> > consistent
> > cookies and with Baptiste's upcoming DNS patches will easily result in
> > pretty
> > dynamic backends!
> >
> > Willy
> >
> >
> I just had a look at the implementation of server-templates. To make it
> work with DNS resolution, we need to find a way to provide a fqdn to the
> default-server directive. This might not be too complicated.

I hadn't thought about this one, good point. At least as a first step
you'll just have to use the same fqdn for all servers (and thus templates).
We definitely want it to be changeable over the CLI.

Willy
Aleksandar Lazic
Re: server templates
April 10, 2017 08:40PM
Am 10-04-2017 20:19, schrieb Willy Tarreau:
> On Mon, Apr 10, 2017 at 05:00:14PM +0200, Baptiste wrote:
>> On Mon, Apr 10, 2017 at 2:30 PM, Willy Tarreau <[email protected]> wrote:
>>
>> > On Mon, Apr 10, 2017 at 10:02:29AM +0200, Frederic Lecaille wrote:
>> > > With server templates, haproxy could preallocate 'server' objects which
>> > > would derive from 'default-server' (with same settings as default server
>> > > settings), but with remaining parameters which are unknown at parsing
>> > time
>> > > (for instance their names, addresses, anything else). In fact here,
>> > names or
>> > > addresses are particular settings: a default server has not any default
>> > name
>> > > or default address.
>> >
>> > Absolutely. And this combined with the recent features of dynamic
>> > consistent
>> > cookies and with Baptiste's upcoming DNS patches will easily result in
>> > pretty
>> > dynamic backends!
>> >
>> > Willy
>> >
>> >
>> I just had a look at the implementation of server-templates. To make
>> it
>> work with DNS resolution, we need to find a way to provide a fqdn to
>> the
>> default-server directive. This might not be too complicated.
>
> I hadn't thought about this one, good point. At least as a first step
> you'll just have to use the same fqdn for all servers (and thus
> templates).
> We definitely want it to be changeable over the CLI.

Thanks all for explanation.

In case I have understood you all right I will be able to add and remove
servers without reloading/restarting haproxy just with some cli
commands, right.
That would be very great ;-)

Will be this also possible for listen/frontend/backend in the next step.
This will be a big challenge because there are so much combinations and
permission issues which can create a lot or headache 8-O

regards
Aleks
Willy Tarreau
Re: server templates
April 10, 2017 08:50PM
On Mon, Apr 10, 2017 at 08:29:05PM +0200, Aleksandar Lazic wrote:
> In case I have understood you all right I will be able to add and remove
> servers without reloading/restarting haproxy just with some cli commands,
> right.
> That would be very great ;-)

Yep that's it.

> Will be this also possible for listen/frontend/backend in the next step.
> This will be a big challenge because there are so much combinations and
> permission issues which can create a lot or headache 8-O

We've had some discussions in the past regarding what could be done for
backends. It's still uncertain and maybe it's the wrong approach, since
a backend is nothing less than a config container and an LB farm with
its LB algorithm. Maybe radically different approaches like splitting
backends to use server groups and being able to associate them on the
fly could make things easier. Or maybe we'll adopt very similar designs
for backend templates as for server templates. This still needs more
thinking. For frontends it's even worse and frontends are also directly
involved in maxconn computation and such stuff. Also most of the time
it will not be possible to bind a frontend after haproxy has lost its
privileges, let alone listen to a unix socket from a chroot. But other
approaches like passing an FD over the CLI could work to some extents.
Also frontends will require passing new certs, something we still can't
do for now. This alone could be a nice improvement for many users compared
to adding frontends (much rarer even in very dynamic environments).

Cheers,
Willy
Frederic Lecaille
Re: server templates
April 20, 2017 02:10PM
Hello HAProxy ML,

On 04/10/2017 05:00 PM, Baptiste wrote:
>
>
> On Mon, Apr 10, 2017 at 2:30 PM, Willy Tarreau <[email protected]
> <mailto:[email protected]>> wrote:
>
> On Mon, Apr 10, 2017 at 10:02:29AM +0200, Frederic Lecaille wrote:
> > With server templates, haproxy could preallocate 'server' objects which
> > would derive from 'default-server' (with same settings as default server
> > settings), but with remaining parameters which are unknown at parsing time
> > (for instance their names, addresses, anything else). In fact here, names or
> > addresses are particular settings: a default server has not any default name
> > or default address.
>
> Absolutely. And this combined with the recent features of dynamic
> consistent
> cookies and with Baptiste's upcoming DNS patches will easily result
> in pretty
> dynamic backends!
>
> Willy
>
>
> I just had a look at the implementation of server-templates. To make it
> work with DNS resolution, we need to find a way to provide a fqdn to
> the default-server directive. This might not be too complicated.
> After this, the magic will happen!!!!

After this first patches for server template new feature, here is a new
set attached to this mail which takes into an account what have been
discussed with Baptiste and Willy.

#0001 patch fixes a minor bug which may be backported to haproxy 1.7 and
1.6.

#0002 upto #0005 patches implement server template feature.

"server-template" new keyword is added and supported in "backend" and
"listen" sections.

Its syntax:
server-temlate <prefix> <nb | range> <fqdn>[:port] <params*>

This may be used to initialize a list of servers with the same
parameters, especially the same FQDN as requested by Baptiste.

#0006 patch updates the documentation.

Fill free to review/comment/test as needed.

Regards,

Fred.
Jarno Huuskonen
Re: server templates
April 21, 2017 09:20AM
Hi,

On Thu, Apr 20, Frederic Lecaille wrote:
> +server-template <prefix> <nb | range> <fqdn>[:<port>] [params*]
> + Set a template for this backend to initialize servers with shared parameters.
> + This server names are built from <prefix> and <nb | range> parameters.
> + May be used in sections : defaults | frontend | listen | backend
> + no | no | yes | yes
> +
> + Arguments:
> + <prefix> a prefix for the server names to be built.
> +
> + <nb | range>
> + If <nb> is provided, this template initializes <nb> servers
> + with 1 upto <nb> as server name suffixes. A range <nb_low>-<nb_high>

s/upto/up to/
"A range" -> "A range of" and "may also been" -> "may also be"
(perhaps native English speakers can check this).

> + may also been used to use <nb_low> upto <nb_high> as server name

s/upto/up to/

> + suffixes.

nb (netblock, number) ? I assume number, so maybe
for example <num> and <num_low>-<num_high> is easier to understand ?

> + Examples:
> + # Initializes 5 servers with srv_1, srv_2 and srv_3 as names,

5 servers (s/5/3/) ?

-Jarno

--
Jarno Huuskonen
Frederic Lecaille
Re: server templates
April 21, 2017 09:30AM
On 04/21/2017 09:15 AM, Jarno Huuskonen wrote:
> Hi,
>
> On Thu, Apr 20, Frederic Lecaille wrote:
>> +server-template <prefix> <nb | range> <fqdn>[:<port>] [params*]
>> + Set a template for this backend to initialize servers with shared parameters.
>> + This server names are built from <prefix> and <nb | range> parameters.
>> + May be used in sections : defaults | frontend | listen | backend
>> + no | no | yes | yes
>> +
>> + Arguments:
>> + <prefix> a prefix for the server names to be built.
>> +
>> + <nb | range>
>> + If <nb> is provided, this template initializes <nb> servers
>> + with 1 upto <nb> as server name suffixes. A range <nb_low>-<nb_high>
>
> s/upto/up to/
> "A range" -> "A range of" and "may also been" -> "may also be"
> (perhaps native English speakers can check this).
>
>> + may also been used to use <nb_low> upto <nb_high> as server name
>
> s/upto/up to/
>
>> + suffixes.
>
> nb (netblock, number) ? I assume number, so maybe
> for example <num> and <num_low>-<num_high> is easier to understand ?
>
>> + Examples:
>> + # Initializes 5 servers with srv_1, srv_2 and srv_3 as names,
>
> 5 servers (s/5/3/) ?

Also note: s/_//

> -Jarno
>

Thank you a lot Jarno for all these remarks. In fact I have published
#0006 patch without double checking. I have already sent an updated
patch to Willy (in private). I am going to redo this ugly patch taking
into an account your remarks too.

Regards.
Frederic Lecaille
Re: server templates
April 21, 2017 09:50AM
On 04/21/2017 09:15 AM, Jarno Huuskonen wrote:
> Hi,
>
> On Thu, Apr 20, Frederic Lecaille wrote:
>> +server-template <prefix> <nb | range> <fqdn>[:<port>] [params*]
>> + Set a template for this backend to initialize servers with shared parameters.
>> + This server names are built from <prefix> and <nb | range> parameters.
>> + May be used in sections : defaults | frontend | listen | backend
>> + no | no | yes | yes
>> +
>> + Arguments:
>> + <prefix> a prefix for the server names to be built.
>> +
>> + <nb | range>
>> + If <nb> is provided, this template initializes <nb> servers
>> + with 1 upto <nb> as server name suffixes. A range <nb_low>-<nb_high>
>
> s/upto/up to/
> "A range" -> "A range of" and "may also been" -> "may also be"
> (perhaps native English speakers can check this).
>
>> + may also been used to use <nb_low> upto <nb_high> as server name
>
> s/upto/up to/
>
>> + suffixes.
>
> nb (netblock, number) ? I assume number, so maybe
> for example <num> and <num_low>-<num_high> is easier to understand ?
>
>> + Examples:
>> + # Initializes 5 servers with srv_1, srv_2 and srv_3 as names,
>
> 5 servers (s/5/3/) ?
>
> -Jarno
>

Here is an updated #0006 patch.

Thank again Jarno.

Regards.
Frederic Lecaille
Re: server templates
April 21, 2017 10:30AM
On 04/21/2017 09:45 AM, Frederic Lecaille wrote:
> On 04/21/2017 09:15 AM, Jarno Huuskonen wrote:
>> Hi,
>>
>> On Thu, Apr 20, Frederic Lecaille wrote:
>>> +server-template <prefix> <nb | range> <fqdn>[:<port>] [params*]
>>> + Set a template for this backend to initialize servers with shared
>>> parameters.
>>> + This server names are built from <prefix> and <nb | range>
>>> parameters.
>>> + May be used in sections : defaults | frontend | listen | backend
>>> + no | no | yes | yes
>>> +
>>> + Arguments:
>>> + <prefix> a prefix for the server names to be built.
>>> +
>>> + <nb | range>
>>> + If <nb> is provided, this template initializes <nb>
>>> servers
>>> + with 1 upto <nb> as server name suffixes. A range
>>> <nb_low>-<nb_high>
>>
>> s/upto/up to/
>> "A range" -> "A range of" and "may also been" -> "may also be"
>> (perhaps native English speakers can check this).
>>
>>> + may also been used to use <nb_low> upto <nb_high> as
>>> server name
>>
>> s/upto/up to/
>>
>>> + suffixes.
>>
>> nb (netblock, number) ? I assume number, so maybe
>> for example <num> and <num_low>-<num_high> is easier to understand ?
>>
>>> + Examples:
>>> + # Initializes 5 servers with srv_1, srv_2 and srv_3 as names,
>>
>> 5 servers (s/5/3/) ?
>>
>> -Jarno
>>
>
> Here is an updated #0006 patch.

Well... wrong patch...
This one should be better.

Regards.
Willy Tarreau
Re: server templates
April 21, 2017 03:50PM
Hey Fred,

that's now merged. I've just build my first haproxy config with 1 million
servers. It takes 8 seconds to start on my laptop, consumes 2.7 GB of RAM
and the stats page is 820 MB long :-)

It's awesome!

Thanks,
Willy
Baptiste
Re: server templates
April 21, 2017 04:10PM
On Fri, Apr 21, 2017 at 3:43 PM, Willy Tarreau <[email protected]> wrote:

> Hey Fred,
>
> that's now merged. I've just build my first haproxy config with 1 million
> servers. It takes 8 seconds to start on my laptop, consumes 2.7 GB of RAM
> and the stats page is 820 MB long :-)
>
> It's awesome!
>
> Thanks,
> Willy
>
>
Great job fred @haproxy.com :)

Looking forward to rebase my DNS patches and mix this feature with the DNS
cache :)
(I don't want your laptop to send 1.000.000 DNS requests to your dns
recurosr every few seconds)

Baptiste
Willy Tarreau
Re: server templates
April 21, 2017 04:30PM
On Fri, Apr 21, 2017 at 04:03:02PM +0200, Baptiste wrote:
> Looking forward to rebase my DNS patches and mix this feature with the DNS
> cache :)
> (I don't want your laptop to send 1.000.000 DNS requests to your dns
> recurosr every few seconds)

You just gave me a good idea of a funny game for the afternoon.

Willy
Frederic Lecaille
Re: server templates
April 21, 2017 04:30PM
Perhaps you should start stopping polluting Jarno's mailbox ;)

On 04/21/2017 04:03 PM, Baptiste wrote:
>
>
> On Fri, Apr 21, 2017 at 3:43 PM, Willy Tarreau <[email protected]
> <mailto:[email protected]>> wrote:
>
> Hey Fred,
>
> that's now merged. I've just build my first haproxy config with 1
> million
> servers. It takes 8 seconds to start on my laptop, consumes 2.7 GB
> of RAM
> and the stats page is 820 MB long :-)
>
> It's awesome!

At least one test passed.
Thank you for testing that Willy. This is one test I have not run among
many others ;) .

> Thanks,
> Willy
>
>
> Great job fred @haproxy.com http://haproxy.com :)

Thank you Baptiste.back.soon@haproxy.com ;) .

> Looking forward to rebase my DNS patches and mix this feature with the
> DNS cache :)
> (I don't want your laptop to send 1.000.000 DNS requests to your dns
> recurosr every few seconds)

Let's review this mixture!
Sorry, only registered users may post in this forum.

Click here to login