Injecting latency into application requests?

Hello All,

is it possible to inject latency into client requests for an application to degrade the user experience?

the goal is to degrade performance of an application by a set amount no matter what the usage is to help expedite migration from one application to another.

Initially I thought of limiting the bandwidth, but when traffic is below the threshold, the application will perform normally. I want the performance to be degraded no matter what the traffic amount is.

Is this possible with an iRule?

thanks in advance,

John.

is after command usable?

after wiki

http://devcentral.f5.com/wiki/iRules.after.ashx

v.10 - iRules and the after command by Colin

http://devcentral.f5.com/Tutorials/TechTips/tabid/63/articleType/ArticleView/articleId/348/v10\-\-iRules-and-the-after-command.aspx

You might be able to call HTTP::collect to hold the request and then use after to call HTTP::release to release the request.

http://devcentral.f5.com/wiki/iRules.http\_\_collect.ashx

http://devcentral.f5.com/wiki/iRules.http\_\_release.ashx

Aaron

It is definitely possible, the problem is that, depending on how you end up writing the rule, you may be delaying all traffic going through the box by that amount. It’s important to avoid loops and blocking commands if you only want to degrade traffic bound for a particular VIP. A collect, as Aaron mentioned, is probably the safest way to suspend a single connection, just be wary of the performance implications of this.

Colin

Hi Aaron/Colin,

Just wonder what is purpose of calling HTTP::collect before using after. May we only use after?

Thanks!

I think you’d want to call HTTP::collect with no collection size to hold the connection and then use ‘after’ to call HTTP::release. This is similar in concept to using HTTP::collect to hold the current request while you perform OCSP or other authentication.

I’m not sure how you could use ‘after’ by itself to stop the request from being sent to the pool or otherwise add latency. I could certainly be missing something on this though :slight_smile:

Aaron

thanks Aaron!

The after command is non blocking. It will fire and allow the connection to continue processing as normal, so there would be no inherent latency. That is, in fact, the entire purpose of the after command: to allow you to continue processing a session while assigning some task to be done at a specified time. To actually pause the connection and add latency, you need to do something that will suspend things, like a collect, a loop, etc. A collect is likely the safest means is all.

I still want to make sure everyone knows this practice is generally a very bad thing, as it can slow things down that you aren’t expecting…but there you have it. :wink:

Colin

Another thought: could you inject a javascript delay function with a stream profile/expression? Change the body tag to include a javascript snippet that just spins CPU cycles for a bit? http://stackoverflow.com/questions/951021/javascript-sleep

The after command is non blocking.you mean after is suspend command but it is non blocking. what is different between suspend and blocking??

sol12962: Some iRules commands temporarily suspend iRule processing

@dubdub - Yep, you sure could. That would be trusting the javascript and putting the delay on the client, however, meaning you’d be responding from the LTM, trusting the client to hang around and wait, and then re-send a new request after a certain delay. While that would work in many situations, it isn’t the same as far as the client is concerned as just inducing delay at the network layer.

@nitass - That is an excellent question, and something I’m going to be documenting in much more detail in a tech tip either this week or next, but the short version is: suspend commands allow OTHER connections to continue processing, I believe I mis-spoke earlier on that, while a blocking command ties up a TMM and makes it sit there waiting for that particular command to finish before it can continue processing anything.

I.E. if I do an after, my connection’s iRule is suspended, but other traffic continues processing just fine. If I put myself into a loop or run an open collect, that TMM is now busy until the command returns, and will be unable to process any other traffic until that time.

That does raise a good question though: Will the after command itself add latency to a connection if you want it to? The more I think about it, yes I suppose it could. I’m just used to thinking of blocking commands as the delay inducing bunch, not the suspending commands since processing continues despite a command suspension.

Something like:

when HTTP_REQUEST {
  after 3000 {
    pool myPool
  }
}

applied to a VIP with no default pool could induce such a delay I suppose. I’ll have to poke at that and test it to be sure, but that makes sense.

Colin

If I put myself into a loop or run an open collect, that TMM is now busy until the command returns, and will be unable to process any other traffic until that time. thanks Colin. anyway, i do not think collect such as HTTP::collect is a blocking command since i am able to get response from another connection while the first connetion is stalled. please let me know if i misunderstood anything here.

[root@ve1023:Active] config  b rule myrule list
rule myrule {
   when HTTP_REQUEST {
        if {[HTTP::uri] equals "/test"} {
                HTTP::collect
        }
}
}

[root@ve1023:Active] config  curl -i http://172.28.19.79/test <<< 1st connection

[root@ve1023:Active] config  curl -i http://172.28.19.79 <<< 2nd connection on another ssh session
HTTP/1.1 200 OK
Date: Wed, 28 Dec 2011 20:47:29 GMT
Server: Apache/2.2.3 (CentOS)
Last-Modified: Fri, 11 Nov 2011 14:48:14 GMT
ETag: "4183e4-3e-9c564780"
Accept-Ranges: bytes
Content-Length: 62
Content-Type: text/html; charset=UTF-8




This is 101 host.

You can get another request, certainly, but not another request from the same TMM. As long as the TMM is in a collect state, it isn’t going to be available to any other traffic.

Colin

thanks again Colin. so, if there is only 1 tmm, only one request can be served at a time, can’t it?

my unit has only 1 tmm. is there anything i missed??

[root@ve1023:Active] config  b tmm
TMM 0.0     process 26866 on CPU 0   TMM id 0   Total TMMs = 1
|     client (cur, max, limit, tot) = (2, 25, 0, 343331)
|     client (pkts,bits) in = (1.398M, 636.9M), out = (762781, 440.5M)
|     server (cur, max, limit, tot) = (2, 25, 0, 343173)
|     server (pkts,bits) in = (1.398M, 637.1M), out = (762747, 440.4M)
|     TMM cycles (total, idle, sleep) = (1.759P, 77.59T, 1.675P)
|     denials (maint, addr full, serv full) = (0, 0, 0)
|             (no serv, no listen, no mem, no lic) = (0, 243981, 0, 0)
|     memory (total, used) = (282.0M, 35.65M)
|     packets (drop, err in, err out) = (0, 0, 0)
|     HTTP requests = 166
|     Conn re-directed = 0

HTTP::collect has an inherent release built in. Try using TCP::collect without a TCP::release, and specify a meg or so of data.

Colin

HTTP::collect with no byte size will stall the connection until HTTP::release is called:

http://devcentral.f5.com/wiki/iRules.http\_\_collect.ashx

Also, if you use HTTP::collect without specifying a length, you must have some non-HTTP event (e.g. AUTH_SUCCESS or NAME_RESOLVED) run HTTP::release, or HTTP processing will not continue, and the collected data will be discarded when the connection times out.

Aaron