[thelist] Which http status code for error in load balancing decision?

Bill Moseley moseley at hank.org
Fri Sep 10 23:39:11 CDT 2010

Somewhat of an odd situation.  Migrating an application from an old code
base to a new one.  I have a load balancer in front that inspects the
requests and decides if the request should go to a server with old code or
with new code.  For the most part it's simple URL inspection by the

But, the new code is partly an AJAX application where the URL space isn't so
separated -- i.e. it's not easy to determine based on the URL where the
request needs to go.  So, in this case the ajax requests include a header
that tells the load balancer where to send the request.  Yes, a bit

Anyway, if a request comes in with, say, and expired session the new code
redirects to the old application where the login page is located.  But, if
this is an ajax request then the client will follow the redirect but include
the header telling it to go to a server with the new code.  The result is
the request comes back to the wrong server which is a redirect loop.  So, in
that case I need to send a response other than a redirect.

Bottom line is a request is sent to the wrong back end server.  The question
is what is the correct response code in this case?  It's not really a 404
because the resource does exist at that URL -- it's just that the load
balancer sent it to the wrong place.  What status should be returned?  Is it
a 500?  Or something in the 400 range?

Will it be the same response for ajax requests (which I know from the
request header) and non-ajax requests?

Bill Moseley
moseley at hank.org

More information about the thelist mailing list