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?

1
  • I think the general term you are looking for here is "sticky session".
    – Jeremy
    Oct 26, 2011 at 18:09

2 Answers 2

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?

1
  • 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, 2011 at 20:30
0

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .