Can I make decisions based on backend response time or response status code?
Short answer
Yes, at two separate levels. Server selection can be made based on response time; for this, Least Response Time, Fastest or Fastest+ is selected in the LB Algorithm field of the vService. The Status Code and Server Response Time conditions, on the other hand, are evaluated after the response arrives; they are used only in On Response actions and do jobs such as adding a header to the response, changing the content or silencing the log, and they cannot send the same request to another Backend Service. For a custom page or a redirect based on error codes, the Show Content for Backend Service Errors and Redirect for Backend Service Errors actions are used.
How Does It Work?
- The request arrives; the Conditional Backend Services (Content Switching) blocks and the LB algorithm select at this stage which Backend Service will handle the request.
- The Backend Service responds; the status code and the response time are known only at this point.
- The actions that run at the response stage (On Response) process the response according to the Status code and Server Response Time conditions and forward it to the client.
Since server selection is made before the response, only the request-stage conditions are listed in the Conditional Backend Services blocks; Status code and Server Response Time are not in this list.
Which Decision Is Made Where in TR7?
| Goal | In TR7 | Note |
|---|---|---|
| Selecting the server that responds fastest | Least Response Time (Time metric: Total time or Response time) · Fastest / Fastest+ | vService → LB algorithm; at the request stage, based on the measured past times |
| Marking a slow response | Server Response Time condition + Add HTTP Header or Set HTTP Header (On Response) | At the response stage; the value is entered in milliseconds |
| Changing the content of a response with a specific status code | Status Code condition + Modify Response Content | At the response stage |
| Excluding specific responses from the log | Status code / Server Response Time condition + Conditional Silent Log (On Response) | At the response stage |
| Showing a custom page on an error code returned by the Backend Service | Show Content for Backend Service Errors | Takes no condition; works with the Error codes list |
| Redirecting to another address on an error code returned by the Backend Service | Redirect for Backend Service Errors | Takes no condition; works with the Error codes list |
| A page or a redirect on the error codes that TR7 generates (e.g. 503 when the Backend Service cannot be reached, 504 on a timeout) | Show Content for Traffic Manager Errors · Redirect for Traffic Manager Errors | Takes no condition |
Common Misconceptions
- "With the Status code condition, I send the request that returns 5xx to another server." The conditions at the response stage do not reroute the request; server selection is made at the request stage. To remove an unhealthy server from distribution, a Health Check profile is assigned to the Backend Service.
- "Least Response Time always looks at the response time." The Time metric field measures Total time (queue + connection + response) by default; for the response time of the server only, Response time is selected.
How it is done in the documentation
Related questions
- What is the difference between On Request and On Response actions?
- What is the difference between Conditional Backend Services and Default Backend Services?
- How do Least Response Time and Least Bandwidth work; why do they sometimes behave like Least Connection?
- Can I act on the size of the response returned by the Backend Service (Response Size (bytes))?
