If I want to load-balance my WCF services, the standard advice is to disable HTTP persistent connections. In other words, ensure that "Keep-Alive" is not active.
This is fine if I want each and every request properly balanced, and if I don't mind the small increase in latency required to re-create a connection on every call.
However, in my case I actually want to avoid the additional latency - and I don't mind if repititious requests through the balancer are "sticky" to one server. Instead I simply want the ability to remove one of the servers from the balanced group, and allow connections to gracefully transition to the other servers.
To achieve this, I need some way for "Keep-Alive" to be de-activated while requests are still in-flight. It would be great to use a WCF message-inspector that, when signalled, adds a "Connection: close" header to replies. Unfortunately, explicitly adding "connection: close" is perhaps not possible.
So my next option is to adjust IIS configuration. While my application is still handling in-flight requests, I would adjust settings in the "Http Response Headers" of the pertinent web site. In there it is possible to "Set Common Headers" and turn "Keep-Alive" off.
Fantastic, except for one thing: changing any configuration causes the app domain with my application to unload. IIS is kind enough to allow existing in-flight connections to bleed-off gracefully when I do this, and the next in-bound request causes the app domain to load again. All subsequent processing will now have "Connection: close" sent in the replies.
Thus no in-bound requests were harmed by making the config change, but I may violate my SLA for request processing because of the time it took to re-load the app domain.
In short, I just want some way to de-activate HTTP persistant connections - without causing the app domain to unload and reload.
I would be glad to have a custom WCF message inspector take care of this, if someone could explain how to overcome the "override" behavior that IIS enforces on the "Connection" HTTP header.