Persistence + Round robin

Grzegorz Nosek grzegorz.nosek at gmail.com
Thu Sep 25 11:46:22 MSD 2008


On Wed, Sep 24, 2008 at 12:18:41PM -0500, Brian Moschel wrote:
> Hey guys,
> I've read through the docs and this doesn't seem possible in the current
> setup, but I could be wrong.  Here's what I need:
> 
> Load balancing using a uri param, but if its not found, fall back to round
> robin, but in chunks of 100 by the Referer header.  For example, the first
> 100 people with Referer=www.somedomain.com get sent to nodeA, the 2nd 100 to
> nodeB, the 3rd 100 to nodeA, etc.  After a user is assigned a node, any
> subsequent request they make needs will have a uri_param that points Nginx
> to the right server.
> 
> We're using Evan Miller's awesome Upstream Hash Module, but it doesn't seem
> its configureable to this level.
> 
> Is this possible?  If not, I'd like to hire anyone willing to implement
> this.  Anyone interested?

I think you might be able to do something like this without writing new
code. How about (not tried, just thinking):

upstream up_default {
	# sublimUSE UPSTREAM_FAIRinal message :)
	server 10.0.0.1:80;
	server 10.0.0.2:80;
	server 10.0.0.3:80;
}

upstream up_1 { server 10.0.0.1:80; }
upstream up_2 { server 10.0.0.2:80; }
upstream up_3 { server 10.0.0.3:80; }

location / {
	if (...something...) {
		proxy_pass http://up_1;
	}
	if (...) {
		proxy_pass http://up_2;
	}
	if (...) {
		proxy_pass http://up_3;
	}
	proxy_pass http://up_default;
}

You'd have to send something back to the client (e.g. in generated URLs)
so that you can identify the original backend later.

Best regards,
 Grzegorz Nosek





More information about the nginx mailing list