Skip to main content
In this lesson you’ll learn how to configure request timeouts and retries using Istio VirtualService resources. We’ll deploy the sample httpbin application and a simple test pod, then demonstrate how to enforce timeouts and retries and observe their effect via requests and proxy logs.

Prepare the cluster and deploy httpbin

  1. Confirm your current namespace (showing labels is optional):
  1. Deploy httpbin and create a test pod with curl installed (image: curlimages/curl):
  1. Verify pods are running:
Example output (trimmed):
  1. Confirm the httpbin service exists:
Example output:
  1. From the test pod, verify a basic request works:
You should see a 200 OK response header.

Implementing a request timeout

Create a VirtualService that enforces a 2 second timeout for HTTP requests to the httpbin service. vs-timeout.yaml:
Apply the VirtualService and confirm it exists:
Test the behavior using httpbin’s delay endpoint:
  • A 1 second delay is within the 2s timeout and should succeed:
Example JSON response:
  • A 2 second delay equals the configured timeout and will be terminated by the proxy:
Typical result:
Explanation: the VirtualService timeout causes the Envoy proxy to abort the request if the upstream service does not respond within the configured period (2s). Increase the timeout if you expect longer upstream processing (for example, try timeout: 5s and /delay/3 to confirm).

Implementing retries

First, remove the timeout VirtualService:
Create a VirtualService that enables retries: vs-retries.yaml:
Apply the new VirtualService:
What this configuration means:
  • attempts: number of retry attempts (3)
  • perTryTimeout: timeout for each individual attempt (1s)
  • retryOn: which error classes trigger retries (here 5xx server errors)

Test retries using httpbin’s status endpoint

httpbin exposes /status/<code> to return arbitrary HTTP status codes.
  1. Confirm a normal GET works:
You should see HTTP/1.1 200 OK.
  1. Generate a 500 and observe the response and proxy behavior:
You will receive HTTP/1.1 500 Internal Server Error as the final response to the client.
  1. To observe retries, tail the httpbin pod’s proxy logs (the istio-proxy container). First get the httpbin pod name and then tail logs:
Look for repeated GET /status/500 log entries — these show the proxy making retry attempts. Example (trimmed) log excerpt:
Those repeated lines indicate the proxy retried the request according to the VirtualService configuration. The client receives the final non-success status (500) unless one of the retries succeeds.

Key fields reference (VirtualService HTTP route)

Notes and tips

Timeouts and retries are configured on the VirtualService HTTP route. Use timeouts to bound request latency, and use retries to handle transient 5xx errors — but be careful: retries increase load on upstreams. Tune attempts and perTryTimeout according to your application behavior.
Common guidance:
  • Apply a sensible per-request timeout so clients don’t wait indefinitely.
  • Use limited retries and short perTryTimeout values to recover from brief upstream failures without causing excessive upstream load.
  • Monitor proxy logs and application metrics to tune the values for your workload.

Example reference snippets

VirtualService with a timeout:
VirtualService with retries:
That wraps up this lesson on configuring timeouts and retries with Istio VirtualServices.

Watch Video

Practice Lab