Timeouts and retries

  • Ingress and provider retries, shared deadlines and handling unknown outcomes.
100%

Illustrative nested retry sequence · read top to bottom; no elapsed times implied

1 One incoming request can produce several gateway-to-application attempts2 Each application execution can produce several provider sends3 An ingress or caller retry can repeat the whole downstream sequenceRetry amplification across ingress, application and provider callsRequest / responseFailure / rejectionOne incoming attempt enters the gateway.The gateway sends the first upstream request to the application.The first application execution starts its provider call; captured HTTP is the illustrated transport option.The outbound Envoy sends its initial upstream attempt.If the configured failure condition and budgets permit, the outbound Envoy sends another attempt. Earlier remote work may still exist.The application receives failure or exhausts its wait for that attempt. This alone does not determine the provider business outcome.The application can start another provider attempt only when safe replay, time, attempts and capacity permit.The gateway can issue a second application attempt after its own retry condition. The first application invocation may still be running.The new incoming execution can start its own application/provider attempt sequence; the downstream budget may multiply if owners are independent.A caller retry can repeat the gateway and application attempt sequence again. This is an optional outer layer, not required behavior.The caller may repeat the whole request. Its maximum attempts are C, including the initial attempt. Its logical deadline, replay safety and deduplication identity must be coordinated with the receiving service. CallerFor a matched HTTP route with retries enabled, ingress Envoy may issue more than one request to an application backend. Call this maximum G total upstream attempts per caller attempt. A gateway-to-application retry can repeat the application pipeline and its downstream calls. A caller-facing timeout or stream reset does not prove earlier application work stopped. Retry conditions and safe methods must be explicit.Istio ingressEnvoyEach incoming gateway attempt can begin another application execution unless admission or a supported deduplication contract prevents it. A client/framework may make A provider attempts per execution. It must spend the same remaining deadline and avoid resetting the business budget on every retry. A deadline limits waiting; cancellation and actual completion must be observed separately. Application JVMThis participant exists only for the illustrated captured, HTTP-visible provider path. A matching outbound HTTP route may issue up to P total upstream attempts for each application attempt. Opaque JVM-owned HTTPS cannot acquire an HTTP retry policy through TCP forwarding alone. The inspected OBRH source templates exclude outbound capture. This lane demonstrates a possible policy owner, not an active-policy claim for that snapshot.Outbound Envoywhen HTTP capturedProvider execution may continue after a client or proxy stops waiting. The provider owns the business effect and supported result/deduplication authority. Repeated sends can repeat effects unless the operation is safe to replay or the provider enforces the original operation identity. Selected providerCaller attempt C1Ingress attempt G1Application attempt A1Provider send P1Envoy retry P2No usable replyApplication retry A2Ingress retry G2New execution starts AagainCaller retry C2, ifallowed

Select a component to trace its direct connections. Drag to pan · Ctrl + wheel or pinch to zoom.

  • Ingress retries can repeat the application while its previous invocation still runs.
  • Application and captured-HTTP outbound Envoy retries can multiply provider sends.
  • For total-attempt caps C/G/A/P: C × G application executions, C × G × A × P provider sends on one nested call path.
  • Example C=1, G=A=P=2: at most two application executions and eight sends before earlier success, deadlines or admission stop them.
  • Coordinate one remaining deadline, safe replay, idempotency, backoff and an attempt budget. The sequence illustrates configured policies, not universal activation.
Timeouts, retries and load amplification

Timeouts, retries and load amplification

Istio HTTP route API v1 · Java 17 example · illustrative retry policies

Retry ownership on Direct and IL routes

  • The representative Direct/IL profiles exclude outbound IPv4/IPv6 traffic from Envoy capture.
  • Selected Direct, IL-OBP and IL-SOA VirtualServices omit explicit timeout/retry fields.
  • Application/client policies remain separate. Check retry policy on the selected inbound and provider routes independently.

Inventory inbound and outbound attempt owners

  • Ingress retries can repeat the application pipeline and its downstream calls.
  • Inventory retry policies at the caller, ingress, application/client and outbound proxy.
Owner Maximum total attempts What it can repeat
Caller C The entire request through ingress
Istio ingress Envoy G per caller attempt An incoming application execution and its downstream work
Application / client library A per application execution The selected provider call
Outbound HTTP-visible Envoy P per application attempt A wire send to the selected provider
  • These are possible policy owners; activation depends on the workload configuration.
  • Route timeout, per-try timeout, client wait and business deadline start at different boundaries.

Separate execution amplification from provider sends

  • Application executions: at most C × G.

  • Provider sends: at most C × G × A × P for one nested call path.

  • Example: C=1 and G=A=P=2 permits up to two application executions and eight provider sends.

  • Count the initial attempt: two retries allow three total attempts.

  • The bound assumes every shown retry layer is active and nests that downstream call.

  • Success, deadlines, admission, completed cancellation and deduplication can reduce the count.

  • Inventory separate downstream operations separately; this is not a universal transaction bound.

  • G2 may arrive while G1 is still running. Keep capacity accounting tied to actual in-flight work.

  • A reset does not prove that the Java task, DB statement or remote transaction stopped.

Coordinate time, admission and replay safety

  • Assign a retry owner for each failure class; bound overlapping retry layers.

  • Before retrying, check remaining time, attempt/concurrency budgets, retryable failure and replay safety.

  • Backoff and jitter spend the same deadline. Jitter spreads retries; it does not bound them.

  • Ingress retries can repeat business side effects; the HTTP method alone is insufficient protection.

  • Preserve an operation identity only with a receiver-supported deduplication/result contract.

  • Use admission or load shedding so retries cannot consume all capacity.

Check capture and HTTP visibility at the relevant hop

  • Ingress: matched HTTP route policy can govern calls to the application.

  • Outbound: provider policy requires capture, visible HTTP and an accepted matching route.

  • Sidecar presence alone proves neither policy is active.

  • JVM-owned HTTPS forwarded as TCP is opaque to HTTP retry/status matching.

  • Proxy TLS termination/origination changes ownership.

  • The inspected OBRH templates exclude outbound capture; this lane shows a possible policy, not verified activation.

Translate examples into budgets before using them

  • The illustrative catalog GET has a 3-second route timeout, 800 ms per try and two additional retries.

  • It demonstrates one retry owner; do not copy that policy to every hop.

  • An ingress route can use the same fields with its own host/gateway/route matching.

  • attempts: 2 permits the initial attempt plus two retries.

  • perTryTimeout also applies to the initial attempt.

  • The route deadline can stop the sequence before all attempts occur.

Illustrative HTTP route — one retry owneryaml
# Generic read-only demonstration, not a deployed workload profile.
# The application makes ONE explicit call; this mesh route owns retries.
# Requires a matching, visible HTTP route and a real catalog Service.
apiVersion: networking.istio.io/v1
kind: VirtualService
metadata:
  name: catalog-read-budget
  namespace: demo
spec:
  hosts:
    - catalog.demo.svc.cluster.local
  gateways:
    - mesh
  http:
    - name: retry-safe-catalog-read
      match:
        - method:
            exact: GET
          uri:
            prefix: /api/catalog/
      timeout: 3s              # Total proxy route budget; includes proxy retries.
      retries:
        attempts: 2            # Two retries, so at most three upstream attempts.
        perTryTimeout: 800ms   # Initial upstream attempt and each retry.
        retryOn: connect-failure,refused-stream,gateway-error
      route:
        - destination:
            host: catalog.demo.svc.cluster.local
            port:
              number: 8080

Keep the application deadline even when another layer retries

  • The Java 17 example makes one explicit attempt within a caller-supplied monotonic deadline.

  • Start the deadline before the work it must cover; do not reset it on retry.

  • Expired waiting triggers a cancellation attempt, not proof of remote completion, rollback or freed capacity.

  • Inventory automatic client/framework retries separately from this example.

Java 17 — one attempt within a caller deadlinejava
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.time.Duration;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

// Generic Java 17 sketch. No main method and no automatic application retry.
// Build/reuse the HttpClient outside request processing. Its connect and pool
// settings are separate concerns. The matching mesh demo owns HTTP retries.
final class ResilienceDeadlineExample {
    static String readCatalog(HttpClient client, URI uri, long deadlineNanos)
            throws InterruptedException, ExecutionException, TimeoutException {
        // Caller creates the deadline before the work it wants to budget:
        // long deadline = System.nanoTime() + Duration.ofSeconds(4).toNanos();
        long remaining = deadlineNanos - System.nanoTime();
        if (remaining <= 0) {
            throw new TimeoutException("Operation budget exhausted before send");
        }

        HttpRequest request = HttpRequest.newBuilder(uri)
                .timeout(Duration.ofNanos(remaining))
                .GET()
                .build();
        var pending = client.sendAsync(request, HttpResponse.BodyHandlers.ofString());
        try {
            remaining = deadlineNanos - System.nanoTime();
            if (remaining <= 0) {
                throw new TimeoutException("Operation budget exhausted after dispatch");
            }
            var response = pending.get(remaining, TimeUnit.NANOSECONDS);
            // A real caller must classify status/business outcome and bound body size.
            return response.body();
        } catch (TimeoutException | InterruptedException failure) {
            pending.cancel(true); // Cancellation request, not proof of remote rollback.
            throw failure;
        }
    }
}
Failure outcomes and recovery

Failure outcomes and recovery

HTTP semantics: RFC 9110 · Java 17 cancellation behavior

Choose recovery from what is known

Observation What is known Recovery consequence
Proven failure before send This attempt did not reach the remote operation Retry only within the remaining budget and applicable failure policy
Explicit rejected result A defined result is available Follow that result contract; do not convert all rejections into retries
Timeout/reset after send or ambiguous progress Remote work may have started or committed Look up/reconcile with the operation authority; repeat only with safe replay or supported deduplication
Gateway retries the application A new incoming execution can overlap the old one Preserve business identity where supported and retain accounting for real in-flight work
  • A timeout describes a wait, not whether the business operation happened.
  • Apply that distinction at both ingress-to-application and application-to-provider boundaries.

Reconcile the original operation

  • Query the authority with the original business-operation identity.
  • Handle committed results, known rejection and unresolved state according to that contract.
  • An idempotency header requires receiver support; a proxy retry or container restart creates no durable result store.

Release capacity when work actually ends

  • Java 17 HttpClient attempts cancellation for the relevant interrupt/future paths.
  • Cancellation can race with sending; resource release may be asynchronous.
  • A stream reset is not a distributed rollback.
  • Track timeout, cancellation request, actual completion and business result separately.