Forum Discussion

maheshme973_569's avatar
maheshme973_569
Icon for Nimbostratus rankNimbostratus
Aug 01, 2013

Getting total bandwidth currently utilized in an iRule

Hope someone can help.

 

 

I have finite internet bandwidth available. There are times when there are too many incoming user requests. I would like to turn away new users (new login requests) based on the amount of internet bandwidth that is already utilized.

 

 

I can think of the following ways to achieve this - but they all get stuck at one point - my iRule needs to know the total bandwidth being utilized so that it can flash the "server busy" page to new users.

 

 

Method 1

 

A simple virtual server with the iRule attached. The iRule can compare the current bandwidth (incoming or outgoing) being utilized by this virtual server. If it is greater than my a pre-defined threshold, the iRule will respond with a "Server Busy" message. This way, new users will not get into the system while users already logged-in will continue to get good experience.

 

 

Method 2

 

Apply a Rate Class to the virtual server. This will ensure the pre-defined bandwidth limit is not exceeded. But unless the above mentioned iRule is applied, new users as well as already-logged-in users will see deteriorating performance.

 

To make the iRule work, I would need to know the cumulative bandwidth being consumed by all connections that have this Rate Class applied.

 

 

Method 3

 

Very similar to Method 2 - but using Bandwidth Controller instead. Same problem - need to know the cumulative bandwidth being utilized by all connections that have this Bandwidth Controller applied.

 

I was hoping the BWC class would have the required information available directly.

 

 

thanks,

 

MM

 

6 Replies

  • not sure if this is useful.

    since 11.1.0, virtual server or pool AVR statistics can be obtained using ISTATS::get command in irule (e.g. ISTATS::get "VIP virtual-server-name counter type). anyway, it is not realtime statistics because statistics needs at least about 10 seconds to be updated (i.e. it is previous update interval statistics). to see all the types, you can run "istats dump" in bash.

    e.g.

    root@(B3900-R67-S12)(cfg-sync Standalone)(Active)(/Common)(tmos) list ltm virtual bar
    ltm virtual bar {
        destination 100.100.100.101:80
        ip-protocol tcp
        mask 255.255.255.255
        pool foo
        profiles {
            http { }
            myanalytics { }
            tcp { }
        }
        rules {
            myrule
        }
        source 0.0.0.0/0
        source-address-translation {
            type automap
        }
        vs-index 3
    }
    root@(B3900-R67-S12)(cfg-sync Standalone)(Active)(/Common)(tmos) list ltm profile analytics myanalytics
    ltm profile analytics myanalytics {
        app-service none
        collect-geo enabled
        collect-ip enabled
        collect-max-tps-and-throughput enabled
        collect-methods enabled
        collect-page-load-time enabled
        collect-response-codes enabled
        collect-url enabled
        collect-user-agent enabled
        collect-user-sessions disabled
        defaults-from analytics
        description none
        notification-email-addresses none
        partition Common
        session-cookie-security ssl-only
        session-timeout-minutes 5
        traffic-capture {
            capturing-for-myanalytics {
                captured-protocols all
            }
        }
    }
    root@(B3900-R67-S12)(cfg-sync Standalone)(Active)(/Common)(tmos) list ltm rule myrule
    ltm rule myrule {
        when HTTP_REQUEST {
      if { [HTTP::uri] eq "/stats" } {
        log local0. "request_throughput: [ISTATS::get "VIP [virtual name] counter request_throughput"]"
        log local0. "response_throughput: [ISTATS::get "VIP [virtual name] counter response_throughput"]"
      }
    }
    }
    
     test
    
    [root@B3900-R67-S12:Active:Standalone] config  tail -f /var/log/ltm
    Aug  1 09:37:47 B3900-R67-S12 info tmm3[9398]: Rule /Common/myrule : request_throughput: 7680
    Aug  1 09:37:47 B3900-R67-S12 info tmm3[9398]: Rule /Common/myrule : response_throughput: 339520
    
     istats dump
    
    [root@B3900-R67-S12:Active:Standalone] config  istats dump
    /var/tmstat/cluster.tm2 [READONLY]: nextBlockId=4064, last update at 2013-08-01 09:39:08
    
    all facts:
       [ GEO=N/A ][concurrent_sessions] = 0 (2013-08-01 09:39:08)
       [ GEO=N/A ][new_sessions] = 0 (2013-08-01 09:39:08)
       [ VIP=/Common/bar ][page_load_time_samples] = 0 (2013-08-01 09:39:08)
       [ VIP=/Common/bar ][request_throughput] = 5760 (2013-08-01 09:39:08)
       [ VIP=/Common/bar ][response_throughput] = 254640 (2013-08-01 09:39:08)
       [ VIP=/Common/bar ][page_load_time] = 0 (2013-08-01 09:39:08)
       [ VIP=/Common/bar ][concurrent_sessions] = 0 (2013-08-01 09:39:08)
       [ VIP=/Common/bar ][max_page_load_time] = 0 (2013-08-01 09:39:08)
       [ VIP=/Common/bar ][server_latency] = 68 (2013-08-01 09:39:08)
       [ VIP=/Common/bar ][tps] = 41 (2013-08-01 09:39:08)
       [ VIP=/Common/bar ][max_server_latency] = 3000 (2013-08-01 09:39:08)
       [ VIP=/Common/bar ][new_sessions] = 0 (2013-08-01 09:39:08)
       [ POOL=200.200.200.101:80 ][page_load_time_samples] = 0 (2013-08-01 09:39:08)
       [ POOL=200.200.200.101:80 ][request_throughput] = 5760 (2013-08-01 09:39:08)
       [ POOL=200.200.200.101:80 ][response_throughput] = 254640 (2013-08-01 09:39:08)
       [ POOL=200.200.200.101:80 ][page_load_time] = 0 (2013-08-01 09:39:08)
       [ POOL=200.200.200.101:80 ][max_page_load_time] = 0 (2013-08-01 09:39:08)
       [ POOL=200.200.200.101:80 ][server_latency] = 68 (2013-08-01 09:39:08)
       [ POOL=200.200.200.101:80 ][tps] = 41 (2013-08-01 09:39:08)
       [ POOL=200.200.200.101:80 ][max_server_latency] = 3000 (2013-08-01 09:39:08)
       [ vip=/Common/bar ][page_load_time_samples] = 0 (2013-08-01 09:39:08)
       [ vip=/Common/bar ][request_throughput] = 0 (2013-08-01 09:39:08)
       [ vip=/Common/bar ][response_throughput] = 0 (2013-08-01 09:39:08)
       [ vip=/Common/bar ][page_load_time] = 0 (2013-08-01 09:39:08)
       [ vip=/Common/bar ][max_page_load_time] = 0 (2013-08-01 09:39:08)
       [ vip=/Common/bar ][server_latency] = 0 (2013-08-01 09:39:08)
       [ vip=/Common/bar ][tps] = 0 (2013-08-01 09:39:08)
       [ vip=/Common/bar ][max_server_latency] = 70 (2013-08-01 09:39:08)
       [ pool=200.200.200.101:80 ][page_load_time_samples] = 0 (2013-08-01 09:39:08)
       [ pool=200.200.200.101:80 ][request_throughput] = 0 (2013-08-01 09:39:08)
       [ pool=200.200.200.101:80 ][response_throughput] = 0 (2013-08-01 09:39:08)
       [ pool=200.200.200.101:80 ][page_load_time] = 0 (2013-08-01 09:39:08)
       [ pool=200.200.200.101:80 ][max_page_load_time] = 0 (2013-08-01 09:39:08)
       [ pool=200.200.200.101:80 ][server_latency] = 0 (2013-08-01 09:39:08)
       [ pool=200.200.200.101:80 ][tps] = 0 (2013-08-01 09:39:08)
       [ pool=200.200.200.101:80 ][max_server_latency] = 70 (2013-08-01 09:39:08)
    
  • Thanks nitass! Looks like something I can use. I'll try it out. And 10 seconds is good enough for me.
  • Finally found time to try it out. Looks like the AVR module is required. I don't have it. Bummer!

     

     

    Any other way to get the throughput information for a virtual server?
  • gbbaus_104974's avatar
    gbbaus_104974
    Historic F5 Account
    While you are at it, look to run the latest hotfix for v11.3

     

    There were (from memory) some AVR related issues fixed since 11.3.0 was first released