title: How to add persistent connection support to a load-balanced HTTP webservice
body: <p>We are working on an HTTP webservice load-balanced using haproxy. The webservice is accessed via SSL. It is a RESTful HTTP service and simply accepts JSON, does some work, and returns JSON. There is no notion of a session.</p>
  
  <p>We have redundant load-balancers set up in front of a pair of redundant webservice servers. Each server sits behind Apache, where Apache is used as a proxy in order to handle SSL and logging. If it matters, our webservice is a Clojure (java) application using compojure (jetty) to handle HTTP.</p>
  
  <p>This is a brief diagram showing the path of a client request through our existing system.</p>
  
  <p><code>client request -&gt; haproxy (load balancing) -&gt; apache (ssl, logging) -&gt; webservice</code></p>
  
  <p>We would like any connection to the load-balancer to establish a persistent connection and then be served by the same server for all subsequent requests sent through that persistent connection. In other words, we don't want a persistent connection to haproxy making requests to more than one webservice server.</p>
  
  <p>How would you recommend that we get this working? How can we "pin" a given connection to the load-balancer to a specific webservice server? How could we prevent accidentally loading down a specific webservice server with multiple intensive requests?</p>