Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login
    Introducing Netgate Nexus: Multi-Instance Management at Your Fingertips.

    Load balance, how long does a sticky connections last ?

    Scheduled Pinned Locked Moved Firewalling
    9 Posts 5 Posters 3.9k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S Offline
      Steffan
      last edited by

      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 Reply Last reply Reply Quote 0
      • K Offline
        Klaws
        last edited by

        @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.

        1 Reply Last reply Reply Quote 0
        • D Offline
          dhatz
          last edited by

          @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)

          1 Reply Last reply Reply Quote 0
          • S Offline
            Steffan
            last edited by

            @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 ?

            1 Reply Last reply Reply Quote 0
            • S Offline
              Steffan
              last edited by

              @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?

              1 Reply Last reply Reply Quote 0
              • J Offline
                jwelter99
                last edited by

                @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.

                1 Reply Last reply Reply Quote 0
                • S Offline
                  Steffan
                  last edited by

                  @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?

                  1 Reply Last reply Reply Quote 0
                  • jimpJ Offline
                    jimp Rebel Alliance Developer Netgate
                    last edited by

                    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.

                    Remember: Upvote with the 👍 button for any user/post you find to be helpful, informative, or deserving of recognition!

                    Need help fast? Netgate Global Support!

                    Do not Chat/PM for help!

                    1 Reply Last reply Reply Quote 0
                    • S Offline
                      Steffan
                      last edited by

                      @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!

                      1 Reply Last reply Reply Quote 0
                      • First post
                        Last post
                      Copyright 2026 Rubicon Communications LLC (Netgate). All rights reserved.