All files from this thread

File Name File Size   Posted by Date  
ngx_round_robin_fix.patch 555 bytes open | download Piotr Sikora 01/26/2010 Read message
ngx_round_robin_fix_v2.patch 551 bytes open | download Piotr Sikora 01/26/2010 Read message
Maxim Dounin
January 26, 2010 02:02PM
Hello!

On Tue, Jan 26, 2010 at 06:31:43PM +0100, Piotr Sikora wrote:

> Hi Maxim,
>
> >This patch has at least two problems I see right now:
> >
> >1. It doesn't handle backup peers.
>
> You are right, fixed version attached.
>
> >2. It does extra unneeded work on each request.
>
> This is done on purpose. This patch is part of patch distributed
> with ngx_supervisord which enables you to start/stop backend servers
> on demand.
>
> But I agree that it could be optimized for mainstream release with
> something like peers->none;

Doing unneeded work on purpose scares me.

I belive correct fix would be to integrate relevant checks into
peer selection loop. This way extra work will be avoided on
normal path and it will be still possible to eventually have
upstreams dynamically configured.

Something like this will do the trick:

--- a/src/http/ngx_http_upstream_round_robin.c
+++ b/src/http/ngx_http_upstream_round_robin.c
@@ -578,7 +578,7 @@ failed:
static ngx_uint_t
ngx_http_upstream_get_peer(ngx_http_upstream_rr_peers_t *peers)
{
- ngx_uint_t i, n;
+ ngx_uint_t i, n, reset = 0;
ngx_http_upstream_rr_peer_t *peer;

peer = &peers->peer[0];
@@ -617,6 +617,10 @@ ngx_http_upstream_get_peer(ngx_http_upst
return n;
}

+ if (reset++) {
+ return 0;
+ }
+
for (i = 0; i < peers->number; i++) {
peer[i].current_weight = peer[i].weight;
}


Maxim Dounin

_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx
Subject Author Posted

100% with upstream / backup server

Matthias Rieber January 26, 2010 11:44AM

Re: 100% with upstream / backup server Attachments

Piotr Sikora January 26, 2010 12:02PM

Re: 100% with upstream / backup server

Maxim Dounin January 26, 2010 12:18PM

Re: 100% with upstream / backup server Attachments

Piotr Sikora January 26, 2010 12:36PM

Re: 100% with upstream / backup server

Maxim Dounin January 26, 2010 02:02PM

Re: 100% with upstream / backup server

Matthias Rieber January 26, 2010 04:22PM

Re: 100% with upstream / backup server

Maxim Dounin January 26, 2010 12:14PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 285
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready