0

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.

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.

This is a brief diagram showing the path of a client request through our existing system.

client request -> haproxy (load balancing) -> apache (ssl, logging) -> webservice

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.

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?

jkndrkn
  • 105
  • 1
  • 4

2 Answers2

1

You're looking for HAProxy's cookie directive, which will ensure that clients stick to the same backend.

As far as avoiding overloading a given backend, you'll be completely dependent on the initial load balancing - moving clients to a different server mid-session doesn't fit with session persistence being enforced from the load balancer. If the load issue is a big one, then maybe reconsider having HAProxy do session persistence, keeping a centralized session state among the backends instead?

Shane Madden
  • 112,982
  • 12
  • 174
  • 248
  • Hi, thanks. A cookie won't be useful in this case because the webservice does not interact with browsers and is sessionless. – jkndrkn Nov 14 '11 at 20:30
0

Using balance source in the defaults block, along with removing option httpclose entries did the trick.

jkndrkn
  • 105
  • 1
  • 4