Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm reading the HAProxy manual and there is a part that I'm not understanding:

request-learn
               If this option is specified, then haproxy will be able to learn
               the cookie found in the request in case the server does not
               specify any in response. This is typically what happens with
               PHPSESSID cookies, or when haproxy's session expires before
               the application's session and the correct server is selected.
               It is recommended to specify this option to improve reliability.

What does it mean "in case server does not specify any in response", specifically what is the server responding to, and what's the point of learning a cookie if the server doesn't specify one?

The issue of "when haproxy's session expires before the application's session" seems an important one but its handling by haproxy doesn't make sense to me here.

share|improve this question
    
Ask the author, perhaps? The wording is weird, but then he's not a native speaker. – sendmoreinfo Oct 28 '12 at 20:23

Usually when you are using a cookie it comes in a response from the back-end server with a "set-cookie" header. This is usually in response to a login. If this doesn't happen then HAProxy will not be able to stick you to the same back-end server

This option allows HAProxy to "learn" about a cookie based on a HTTP Request not just a HTTP Response with "set-cookie."

To answer your specific questions:

"What is the server responding to?" Any HTTP Request

"What is the point of learning a cookie the server did not provide?" It allows HAProxy to perform stickiness when you have a server that does non-standard things and doesn't/can't provide the cookie as expected. An example he provides is the "PHPSESSID" cookie.

"HAproxy's session expires before the application's session?" HAProxy stores the cookies to perform stickiness. They have a TTL before they are no good anymore. In the case that the TTL for the back-end server is longer than the TTL for HAProxy, HAProxy will forget the cookie before the back-end server. The client will have the Cookie in the request and HAProxy will be able to re-learn the cookie.

Your skepticism is well placed because if your back-end servers don't replicate session information then this option is of limited usefulness in the TTL case. It still applies to the non-standard cookie case scenario however.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.