Prepare the cluster and deploy httpbin
- Confirm your current namespace (showing labels is optional):
- Deploy httpbin and create a test pod with curl installed (image:
curlimages/curl):
- Verify pods are running:
- Confirm the httpbin service exists:
- From the test pod, verify a basic request works:
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:- A 1 second delay is within the 2s timeout and should succeed:
- A 2 second delay equals the configured timeout and will be terminated by the proxy:
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:attempts: number of retry attempts (3)perTryTimeout: timeout for each individual attempt (1s)retryOn: which error classes trigger retries (here5xxserver errors)
Test retries using httpbin’s status endpoint
httpbin exposes/status/<code> to return arbitrary HTTP status codes.
- Confirm a normal GET works:
HTTP/1.1 200 OK.
- Generate a 500 and observe the response and proxy behavior:
HTTP/1.1 500 Internal Server Error as the final response to the client.
- To observe retries, tail the httpbin pod’s proxy logs (the
istio-proxycontainer). First get the httpbin pod name and then tail logs:
GET /status/500 log entries — these show the proxy making retry attempts. Example (trimmed) log excerpt:
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.- Apply a sensible per-request timeout so clients don’t wait indefinitely.
- Use limited retries and short
perTryTimeoutvalues to recover from brief upstream failures without causing excessive upstream load. - Monitor proxy logs and application metrics to tune the values for your workload.