Forum Discussion

DCO_21192's avatar
DCO_21192
Icon for Nimbostratus rankNimbostratus
Nov 30, 2007

Irule to LB traffic based on least connections

I am looking information on how I can build an iRule to load balance traffic based on leat connections. Here are the dirty details.

 

 

We have an application that does not keep state in a database, the session state is kept at the application layer. There are 5 Pools of Web servers and each pool is tied to specific application servers. Because of this we have built an iRule that issues a persistance cookie that will direct a user to the same pool in the event of a disconnect during their session. In the same iRule if a new connection (connection without a cookie) is made it is directed to the default pool. The results is an imbalance of connections to specific pools. I must add that the GTM is using round robin to balance traffic between two locations, and an added problem are the mega proxy DNS cache issues we are seeing. There is much more to the design than I am relating here, the bottom line is can we use information already in the GTM/LTM to load balance traffic based on least connections in an iRule no matter what the DNS resolution was from the GTM.

5 Replies

  • There is a least connections load balancing algorithm for LTM and GTM. You can get more info on these modes in the config guide for your version on Askf5.com. I would think that you could specify a persistence method on GTM to ensure requests make it back to the correct datacenter, and then use a persistence method at the LTM level to ensure requests make it to the correct app server. Have you tried this yet?

     

     

    Aaron

     

     

  • Yes this is in place already, the real issue revolves around cached DNS responses by mega proxies. The GTM has a wide IP for each location pool and are balanced using round robin. Each pool has a DNS A record. There are 5 pools at each location and the pools are balanced using least connections. Once a mega proxy (such as AOL) caches a DNS response then everyone making a connection from AOL will go to the same pool, thus overloading the APP servers behind the web apps. What I am looking to do is basicly re-balance the connections with an iRule rather than using the default pool.
  • What criteria would you want to use in an iRule to break up the AOL users?

     

     

    If the major issue is that when you treat anyone coming from AOL subnets as a single client the web servers get overwhelmed, you could try disabling the mapping of AOL clients on the LTM's. Assuming you use cookie-based persistence on the LTM's, you would get an even dispersement of requests at the server level. Of course, you'd still potentially run into issues with one datacenter receiving all of the AOL requests. But I don't really see a way around this if you need to treat all AOL users as one for persistence at the datacenter (GTM) level.

     

     

    Aaron
  • It's not just AOL but any ISP that uses a mega proxy or caches a DNS response longer than the configured TTL. The iRule that is deployed is using session persistance to the pool that it was assigned based on the load balance scheme we have configured. If a new connection is made and does not have a cookie it is then sent to the default pool so if by chance the connection is coming from an ISP that has cached a specific DNS response for a pool the connection is sent to that pool. I know this is normal behavior and out of our control, the real issue is the application not keeping state information in the database. So until the delvelopers come up with a solution to their problem we have been asked to try and fix it using the load balancers. I guess the bottom line question is; Does the GTM/LTM store information about least connections somewhere and if it does can an iRule be used to make a decision based on this information? If it is possible what would the impact be on the LTM's if we have almost every connection go through the load balance process essentialy a second time.
    • trx_94323's avatar
      trx_94323
      Icon for Nimbostratus rankNimbostratus

      Hello did you ever accomplish an IRule for least connections? I am in the similar situation where I would like control the load balancing via IRules.

       

      Thanks in advance.