Load balance, how long does a sticky connections last ?



  • HI guys,

    I'm not sure where to post this, so i just put it here (admin, please move if wrong place)

    So, i have configured load balancing for a http cluster, and it works. i also use sticky connections BUT i noticed that theese connections gets "Unsticked" pretty fast, so my questions are:

    1. How longs does a connection have to be inactive for the stickyness to go away?
    2. Can i change the amount of time ?

    Thanks!



  • @Steffan:

    1. How longs does a connection have to be inactive for the stickyness to go away?

    Apparently, noone knows.

    @Steffan:

    2. Can i change the amount of time ?

    While I have come across some of the source code delaing with load balancing , I haven't seem anything related to the duration of the stickyness. I am afraid it cannot be changed, not even in a reasonably complicated way.

    Anyway, sticky connections are a kludge, a cheesy workaround known not to reliably work.

    If your web application is not designed to support load balancing, you are basically SOL. While quite a few mechanisms have been developed to "magically" enable lb/fo for "stupid" applications, none of these actually work perfectly. Discuss the issue with your web developers.



  • @Klaws:

    @Steffan:

    1. How longs does a connection have to be inactive for the stickyness to go away?

    Apparently, noone knows.

    @Steffan:

    2. Can i change the amount of time ?

    While I have come across some of the source code delaing with load balancing , I haven't seem anything related to the duration of the stickyness. I am afraid it cannot be changed, not even in a reasonably complicated way.

    If you're referring to pf's loadbalance/failover, then run the following command from CLI:
    pfctl -st
    and check the value of src.track

    If you're referring to relayd, I'm not sure (haven't used it)



  • @Klaws:

    @Steffan:

    1. How longs does a connection have to be inactive for the stickyness to go away?

    Apparently, noone knows.

    @Steffan:

    2. Can i change the amount of time ?

    While I have come across some of the source code delaing with load balancing , I haven't seem anything related to the duration of the stickyness. I am afraid it cannot be changed, not even in a reasonably complicated way.

    Anyway, sticky connections are a kludge, a cheesy workaround known not to reliably work.

    If your web application is not designed to support load balancing, you are basically SOL. While quite a few mechanisms have been developed to "magically" enable lb/fo for "stupid" applications, none of these actually work perfectly. Discuss the issue with your web developers.

    Thanks for your answer.
    The problem is i use php sessions, and i have multiple webservers, hoping i could get the users to keep theyr session and not start a new one at random times, i used sticky connections. And i cant put a php session i MySQL, if i could i would have done that instead (Or is this possible???)
    I was thinking of making a shared NFS mount on every webserver and store the php session there, then sticky connections would be uneccesary, but is this a good idear ?



  • @dhatz:

    @Klaws:

    @Steffan:

    1. How longs does a connection have to be inactive for the stickyness to go away?

    Apparently, noone knows.

    @Steffan:

    2. Can i change the amount of time ?

    While I have come across some of the source code delaing with load balancing , I haven't seem anything related to the duration of the stickyness. I am afraid it cannot be changed, not even in a reasonably complicated way.

    If you're referring to pf's loadbalance/failover, then run the following command from CLI:
    pfctl -st
    and check the value of src.track

    If you're referring to relayd, I'm not sure (haven't used it)

    I think i am referring to relayd (in PFsense i go to Services > Load balancer)
    I fired the command you gave me, and i returned "0s" on src.track. but i guess by pfsense loadbalance/failover you mean a dual pfsense setup, right ? so this src.track does not have anything to do with my issue, or does it?



  • @Steffan:

    HI guys,

    I'm not sure where to post this, so i just put it here (admin, please move if wrong place)

    So, i have configured load balancing for a http cluster, and it works. i also use sticky connections BUT i noticed that theese connections gets "Unsticked" pretty fast, so my questions are:

    1. How longs does a connection have to be inactive for the stickyness to go away?
    2. Can i change the amount of time ?

    Thanks!

    1. It's depending on the state table size and the policy for removing idle connections from the state table.

    2. Yes, in the advanced/firewall+NAT you can change the firewall optimization option to HIGH-LATENCY which will be slower to clear idle connections from the state table and therefore the stickyness will last longer.  Note: this will cost you a bit of  RAM and CPU.

    Probably some sysctl's as well that can be tweaked as well.

    But the best is to setup correct session sharing on your servers.



  • @jwelter99:

    1. It's depending on the state table size and the policy for removing idle connections from the state table.

    2. Yes, in the advanced/firewall+NAT you can change the firewall optimization option to HIGH-LATENCY which will be slower to clear idle connections from the state table and therefore the stickyness will last longer.  Note: this will cost you a bit of  RAM and CPU.

    Probably some sysctl's as well that can be tweaked as well.

    But the best is to setup correct session sharing on your servers.

    Thanks for your answer.
    I tried playing with the optimization option but is was not enough, it's still too fast..
    How would you suggest to make session sharing on two apache servers (Linux)? What is the best way to do this?


  • Rebel Alliance Developer Netgate

    Sticky associations are kept as long as there are states between the client and server. When the states all go away, the association is dropped.

    You can extend that time by raising the value for source tracking, which is an option on 2.1 right underneath the sticky checkbox.



  • @jimp:

    Sticky associations are kept as long as there are states between the client and server. When the states all go away, the association is dropped.

    You can extend that time by raising the value for source tracking, which is an option on 2.1 right underneath the sticky checkbox.

    Great!
    I'm currently running version 2.0.1-release so that's not an option for me.
    I am currently looking at different ways to share session data between my webservers, i think thats the best way to go..

    But thanks for all the great answers, you all lead me into the right direction!


Log in to reply