Lua/Redis Routing with Failover

Rick Richardson rick.richardson at gmail.com
Wed Feb 1 03:27:37 UTC 2012


I have a requirement to route dynamically by domain to a set of all
participating peers similar to the Dynamic Request Routing Based on
Redis in Open Resty, the difference is that if one upstream peer is
down, I'd like to fail over to the next one.  So Redis would return a
priority-sorted list of upstream peers for any given domain instead of
1.

My plan is to build make an array of peer structs available to lua so
that my lua script can populate the array on each upstream.init.  Then
a custom upstream->peers.get/free would set or reset the current
chosen peer.

I think that this would mean that I would have to have a custom upstream.

Is there an easier way?



More information about the nginx-devel mailing list