Lua/Redis Routing with Failover

Rick Richardson rick.richardson at gmail.com
Thu Feb 2 04:41:00 UTC 2012


Right.  So I'm basically doing just that,  I've made an


upstream /backend {
   redis_route;
   keepalive;
}

upstream /redis {
 ...
}

location /servers {
  internal;
  redis2_query get $host;
  redis2_pass redis_cluster;
}

location / {
  ...
  proxy_pass backend;
}

I am working on a module called redis_route which is an upstream
patterned after rr
This executes a subrequest to /servers which returns a Redis List of
uris. I then parse those
URIs and put them into an array which is then accessed when the
upstream->peer.get callback is called requesting a new server.
I store the rest, so if that backend uri fails, upstream->peer.get
will be called for the next one on the list.

Does this make sense?

/
On Wed, Feb 1, 2012 at 11:19 PM, agentzh <agentzh at gmail.com> wrote:
> On Thu, Feb 2, 2012 at 12:05 AM, Rick Richardson
> <rick.richardson at gmail.com> wrote:
>> Sorry for the confusion. I don't want failover/backup for redis servers, I
>> want the redis request to return multiple upstreams that I can proxy to with
>> proxy_pass.
>>
>> E.g. I get a request for Foo.com. I ask redis for a list of upstream servers
>> to which I can serve Foo.com.  I then feed the entire list somehow into
>> proxy_pass.  It then performs its normal htttp_upstream operation as if it
>> had a standard list of peers in an upstream.
>>
>
> Sorry for the misunderstanding :)
>
> I think we could just patch ngx_proxy and mimic
> ngx_http_upstream_create_round_robin_peer to dynamically construct a
> peer list for the current request, just like how ngx_proxy does now
> for multiple A records corresponding to a single host name if the
> dynamic resolver is used. You can have a try ;)
>
> Maybe it makes sense to provide a generic interface for ngx_proxy to
> make such things easy.
>
> Best regards,
> -agentzh
>
> _______________________________________________
> 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