Forum Discussion

Brian_Ott_11267's avatar
Brian_Ott_11267
Icon for Nimbostratus rankNimbostratus
Feb 03, 2005

Compression based on client

Is it possible to construct an iRule to turn on compression based on a client's speed?

 

 

We find compression to be much less effective for many of our customers, and would like to turn it on for slower customers such as those on dialup and possible 256k/lower DSL.

 

 

Any thoughts in regards to how to determine the client's possible speed? Based on mss or mtu is my only idea.

 

 

This was one of the selling points for us in regards to the 3400 box, so I was curious what the most effective way to implement this might be.

 

 

-Brian.

9 Replies

  • rapmaster_c_127's avatar
    rapmaster_c_127
    Historic F5 Account
    Yes, you can definitely do this. Here are some commands that you could use to help determine the type of client. We have been working on improving some of them in 9.0.5, so you may want to hold off on getting too elaborate with them until then.

    IP::hops

    This gives you the estimated number of hops the peer takes to get to you.

    TCP::rtt

    This gives you the smoothed round-trip time estimate between you and the peer. Note that as an implementation detail, the unit is in 1/32 of a millisecond. (Sorry, that's a kernel implementation detail we had to use to avoid floating point.)

    Note that the rtt takes some time to converge, so we have the following in order to cull outliers:

    ROUTE::rttvar

    This is the statistical variance of rtt in 1/16 ms intervals.

    TCP::bandwidth

    This is an estimate of the upload bandwidth (i.e. how much data we can optimally push to the peer without causing recoveries or drops) in bytes per second. Note: due to a bug in our implementation, this value is incorrect in current releases. It has been fixed for 9.0.5.

    And, as you mentioned, we of course have:

    TCP::mss

    With these metrics, you can imagine just how good the possibilities are for traffic analysis. Of course, you can also use things like

    IP::tos

    To both get and set the diffserv parameters for traffic, if you have upstream devices doing traffic classification for you.

    Here is a simple rule example using TCP::mss that disables compression to larger MSS clients (you must have it enabled on the profile, so the rule can only disable it.)

     
        when HTTP_REQUEST { 
            if { [TCP::mss] >= 1280 } { 
                COMPRESS::disable 
            } 
        } 
     

    Let us know how it goes, and please feel free to post your suggestions and enhancements!
  • I tried the following and got the following error. How do I change the HTTP profile?

     

     

     

     

    when CLIENT_DATA {

     

    if { [TCP::rtt] >= 1000 } {

     

    profile HTTP_maxcompress

     

    } elseif { [TCP::rtt] >= 500 } {

     

    profile HTTP_mincompress

     

    } else {

     

    profile HTTP

     

    }

     

    }

     

     

    01070151:3: Rule [Rap_iRule] error:

     

    line 3: [undefined procedure: profile] [profile HTTP_maxcompress]
  • bl0ndie_127134's avatar
    bl0ndie_127134
    Historic F5 Account
    We don't allow you to switch http profiles from rules. If you are trying to set the compression level dynamically, you may be able achieve the same thing using this rule
    COMPRESS::gzip level [ 1 .. 10 ]
    where '9' is a value at which you get the highest level of compression. You can call this rule as many times as you like and the value is sticky for the life time of that connection.
  • rapmaster_c_127's avatar
    rapmaster_c_127
    Historic F5 Account
    I think you want to latch HTTP_REQUEST rather than CLIENT_DATA. CLIENT_DATA occurs after a TCP::collect rule, which may or may not have triggered any HTTP events. The safest place to check this metric is in HTTP_REQUEST.
  • bl0ndie_127134's avatar
    bl0ndie_127134
    Historic F5 Account
    Correction, the rule should read
    COMPRESS::gzip level [ 1 .. 9 ]
    Actually, I would have preferred '11' but oh well.
  • Hi,

     

     

    Can you confirm if the F5 LB's support the option to route traffic based on a diffserve value? I would look to have the value set by another system downstream.

     

     

    Thanks

     

     

    Marc
  • Yes, if you use the IP::tos and/or LINK::qos

     

     

    http://devcentral.f5.com/wiki/default.aspx/iRules/IP__tos.html Click here

     

     

    http://devcentral.f5.com/Wiki/default.aspx/iRules/LINK__qos.html Click here