Forum Discussion
mario_112401
Nimbostratus
May 30, 2008HTTP response timeout
Hello, when an HTTP_REQ arrives, LTM should send the request to one server in the pool and wait for 1 sec for the server's answer: if TO expires, LTM should send a specific answer to the client and drop the server's real answer arrived after the TO. Can anyone help me writing an iRule ? Thanks in advance. Mario
9 Replies
- hoolio
Cirrostratus
I don't think it's really possible to do exactly what you've described with an iRule. I can't think of a way to start a counter and then check to see if it's passed the timeout x number of seconds later. The check would have to be done in an event.
The closest that I can think of is to set a timer when the HTTP request headers are parsed in HTTP_REQUEST. You could then check the elapsed time in the HTTP_RESPONSE event (when LTM parses the server's response HTTP headers). If the response was received in less than 1 second you could allow the response to be sent back to the client. If the response comes in after 1 second you could drop the response when it's received and send back a different response to the client.
Out of curiosity, why do you need to set such a low timeout? Most HTTP clients can handle a longer wait than one second.
Aaron - mario_112401
Nimbostratus
Hi Colin, thanks for your answer. About your curiosity, this is a requirement for a project (I don't know the reason ... :-). About your suggestion, can you send me an example ? Thanks in advance. Mario - mario_112401
Nimbostratus
Sorry, my reply is addressed to Aaron (Hoolio) ... BR Mario - hoolio
Cirrostratus
Mario,
Here's a first attempt (untested):when HTTP_REQUEST { Save the start time when HTTP request headers were parsed set start_time [clock clicks -milliseconds] } when HTTP_RESPONSE { Check if the response headers from the server were parsed in more than 1000ms if {[expr {[clock clicks -milliseconds] - $start}] > 1000}{ Respond back to client HTTP::respond 200 content "Response time was too long" } }
The default pool on the VIP will be used. If you want to add pool selection logic to the rule, you can do it in the HTTP_REQUEST event.
Aaron - mario_112401
Nimbostratus
Hi Aaron, thank you very much for your help. Kind regards, Mario - eantolo_25676
Nimbostratus
Hi,
I know there is also a command : "when HTTP_REQUEST timing on " but i don't know if this can be used for this scope.
BR, - hoolio
Cirrostratus
The timing command allows you to monitor how many CPU cycles are used when processing a command or event. It's strictly for reporting purposes. You can get more detail on the command from the timing wiki page (Click here).
Aaron - mario_112401
Nimbostratus
Hello Aaron (Hoolio), I have tested your example and it works. However, it doesn't cover exactly what requested: in fact the HTTP response for timeout too long should be sent by BIGIP if a timer of 1 sec expires and the real server doesn't send the answer. In your example the irule is instead triggered when the BIGIP receives the answer by the server. I think we should use a timeout event but I can't find anything like this. Do you have any idea ? Thank you very much for your help. Mario - hoolio
Cirrostratus
Hi Mario,
You're correct. The rule does exactly that. This is the best that can be done with current functionality. If, F5 provides a true timer mechanism at some point, you could update the rule to respond without depending on the server response to trigger your response.
Aaron
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects
