[PATCH] Random peer selection for implicit upstream defined by proxy_pass

Anton Jouline juce66 at gmail.com
Fri Sep 28 20:08:30 UTC 2012


hi Maxim,

yes, attribution in CHANGES.ru would be great, thanks!
In Russian, my name is spelled as: Антон Жулин

One comment on changeset 4872:

On line #1385, wouldn't you want to call ngx_resolver_rotate()
instead of ngx_resolver_dup() ? To cover the case of the name
not being cached at all for some odd reason - like, if TTL is set
to 0 seconds. Or, if TTL is really small, which would also skew
the distribution to use the 1st addr a lot more than others.



On Fri, Sep 28, 2012 at 11:51 AM, Maxim Dounin <mdounin at mdounin.ru> wrote:
> Hello!
>
> On Wed, Sep 19, 2012 at 10:39:01PM -0700, Anton Jouline wrote:
>
> [...]
>
>> So, i decided instead to take a look at ngx_resolver code and
>> it turned out that it's actually very simple to randomize there,
>> since there is code already that copies the array from one place
>> in memory to another. Looked like that was ideal place for
>> changing the order via simple rotation.
>> Here is the new patch:
>>
>>
>>
>> --- a/src/core/ngx_resolver.c
>> +++ b/src/core/ngx_resolver.c
>> @@ -88,6 +88,8 @@ static void *ngx_resolver_calloc(ngx_resolver_t *r,
>> size_t size);
>>  static void ngx_resolver_free(ngx_resolver_t *r, void *p);
>>  static void ngx_resolver_free_locked(ngx_resolver_t *r, void *p);
>>  static void *ngx_resolver_dup(ngx_resolver_t *r, void *src, size_t size);
>> +static in_addr_t *ngx_resolver_dup_rotated(ngx_resolver_t *r, in_addr_t *src,
>> +    u_short n);
>>  static u_char *ngx_resolver_log_error(ngx_log_t *log, u_char *buf, size_t len);
>
> [...]
>
> Slightly modified version committed, thanks:
>
> http://trac.nginx.org/nginx/changeset/4872/nginx
>
> I'm a bit unsure - would you prefer Russian attribution in
> CHANGES.ru?  (We usually write names in Russian in CHANGES.ru if
> contributor is from exUSSR/speak Russian.)
>
> Maxim Dounin
>
> _______________________________________________
> nginx-devel mailing list
> nginx-devel at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx-devel



More information about the nginx-devel mailing list