<div dir="ltr">Ok, thanks.<div><br></div><div>Can you imagine any other viable way to pass some information to each server? It doesn't need to change between server restarts.</div><div>I may use a distinct variable for each of them but this seems ugly and error-prone...</div><div><br></div><div>In case you are curious why would I need this, let me explain.<br></div><div>Upstream directive support "hash consistent" method and in that case it uses `ketama` algorithm. That means that each server assigned a key and depending on its value (actually hash of that value) each server mapped to a multiple points on the ketama ring. So far so good.</div><div>Documentation says that keys distribution is compatible with Perl Cache::Memcached::Fast module. And that means that key for each server is "$ip\0$port" (or something else for unix sockets, doesn't matter).</div><div>This means that if server ip changes, position of server points on ketama ring will change too. Now, I'm balancing via this upstream not memcacheds or other rather ephemeral storages but files. Each server in the upstream have a hundreds of gigabytes of files. And I would like to avoid rebalancing all these files in case of public ip changes.</div><div>So my idea was to pass a key for each server via parameter. Actually, to preserve compatibility with current keys, I would pass a base64 of "$ip\0$port" value, decode it during module init and happily use it for ketama purposes. And be safe against servers redeployments.</div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature"><div dir="ltr"><div><br></div>Best regards,<br>Dmitriy Shalashov<br></div></div></div>
<br><div class="gmail_quote">2015-02-12 16:36 GMT+03:00 Maxim Dounin <span dir="ltr"><<a href="mailto:mdounin@mdounin.ru" target="_blank">mdounin@mdounin.ru</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello!<br>
<span class=""><br>
On Wed, Feb 11, 2015 at 09:40:12PM +0300, Дмитрий Шалашов wrote:<br>
<br>
> Hi!<br>
><br>
> As far as I see Nginx have limited number of possible server parameters<br>
> inside upstream block. It is enforced by function ngx_http_upstream_server for<br>
> example.<br>
> Now, having my own upstream module how can I approach the task of adding a<br>
> couple more parameters to a servers inside it?<br>
<br>
</span>You can't.  Parameters of the "server" directive are not currently<br>
extendable.<br>
<span class=""><br>
> I would like to find a solution without resorting to patch Nginx source<br>
> code, resilient to Nginx updates (self-contained, in other words) and<br>
> having that -- as simple as possible.<br>
><br>
> I have to confess that this module is the only piece of C code I've ever<br>
> wrote, and I was "taking inspiration" from other modules :-)<br>
> My best guess so far is overriding ngx_http_upstream_server (googling shows<br>
> it's likely possible) with my own function which will find my new<br>
> parameters, remove them from cf->conf and then call original function.<br>
<br>
</span>While this approach may work, it will likely result in big<br>
problems in the future.<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
Maxim Dounin<br>
<a href="http://nginx.org/" target="_blank">http://nginx.org/</a><br>
<br>
_______________________________________________<br>
nginx-devel mailing list<br>
<a href="mailto:nginx-devel@nginx.org">nginx-devel@nginx.org</a><br>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx-devel" target="_blank">http://mailman.nginx.org/mailman/listinfo/nginx-devel</a></font></span></blockquote></div><br></div>