<div dir="ltr">I'd like to propose - with respect and a clear admission I don't understand your exact use case here - that you're doing it wrong. The point that made me think this is:<div><div class="gmail_extra">

<br><div class="gmail_quote">On 4 March 2014 14:29, Ed James (Alt) <span dir="ltr"><<a href="mailto:ed.james.spam@gmail.com" target="_blank">ed.james.spam@gmail.com</a>></span> wrote:</div><div class="gmail_quote">
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
                <div>What we want is to direct a user’s requests based on an application setting - this could be in the db, memcache, redis, whatever. The retrieval of the setting is another problem I think. It’s the logic around that setting's value that I’m interested in.</div>

</blockquote><div><br></div><div><br></div><div>This suggests it's an attribute of the user that determines the routing. I think that's a poor design. We just had a similar decision to make internally, and in the end we realised this was going to get very messy, very quickly.</div>

<div><br></div><div>The application setting you're talking about is directly equivalent to a user role if you abstract it far enough, what this configuration would lead to is code duplication: some servers over here have slightly different code to servers over here, and we're routing to them based on a setting per user.</div>

<div><br></div><div>What makes more sense is have the same code run everywhere and to handle the changes according to application setting within the method or as a before_filter. </div><div><br></div><div>If it is really very remarkably different, then it's a separate service that should be in a separate application on separate servers and you should deal with it accordingly.</div>

<div><br></div><div>Load balancers exist to ensure high availability and in ASGs on AWS, ELBs also allow you to scale up/down resources based on load. That's it. Trying to get any load balancer - whether it be an ELB or HAProxy or Varnish or something else - to start managing application logic seems like a bad idea. </div>

<div><br></div><div>Business logic lives in apps not in the load balancer.</div><div><br></div><div>And now, where I contradict myself: we have an AngularJS client for a new product we're building as well as native iOS and Android apps. They talk to a whole host of micro-services because we have a full-on SOA at the back end. </div>

<div><br></div><div>In order to be able to QA properly and also move users over to new versions of services a few at a time we have on user sign-in a call to retrieve the top level service URLs: <a href="http://servicex.domain.com">servicex.domain.com</a> and <a href="http://servicey.domain.com">servicey.domain.com</a>, etc.</div>

<div><br></div><div>These are defaults we can over-ride per user, so I can move one QA guy onto a new version of a service whilst leaving everybody else intact, and then to understand load I can move people over. </div><div>

<br></div><div>Could I (ab)use this to mimic your requested functionality? Sure, but I know that's going to be hard to manage so I'm more likely to use it for a few hours at a time at most. Seamless roll-on/roll-off of service updates is great. Using it as a permanent fix to avoid a conditional branch in an action? Probably not so great long-term.</div>

</div></div></div></div>