Video in progress
You are considering introducing a service mesh (Istio, Linkerd) for Java microservices. When is it worth it, and what hidden problems appear?
A mesh gives mTLS, traffic management and uniform telemetry without touching application code, which is useful in a polyglot, many-service system. The cost: extra latency and resources, harder debugging, startup/shutdown ordering with the sidecar, and duplication with retries inside the app.
📖 Answer
When it is worth it:
- a security requirement: mTLS and identity between services, without managing certificates in every service;
- services in different languages: Resilience4j in Java does not exist in a Go or Node service, and the mesh gives all of them the same policy;
- fine-grained traffic control: weighted splits for canaries, header-based routing.
If all services are Spring Boot and there is no mTLS requirement, the benefit of a mesh shrinks a lot, since libraries and Micrometer cover much of it.
Problems you meet with Java:
Startup order: the app tries to connect to the DB or Config Server before the sidecar is ready and fails. In Istio, holdApplicationUntilProxyStarts solves this, and in Kubernetes 1.29+ so do native sidecars (initContainers + restartPolicy: Always).
Shutdown order: if the sidecar goes down before the app after SIGTERM, outgoing requests during graceful shutdown fail. Again native sidecars, or the proxy's drain settings.
Multiplying retries: 3 retries in the app and 3 in the mesh turn one failure into 9 requests, and along a chain that grows exponentially. Keep retries in one place.
Timeouts: a mesh timeout of 15 s and a RestClient timeout of 30 s in the app: nobody knows which one applies.
Resources: a sidecar in every pod costs 50-100 MiB of RAM and some CPU, which is significant at 500 pods. Ambient or sidecar-less modes reduce this, but they are new and behave differently.
Long-lived connections: with gRPC and HTTP/2, load balancing must happen at the request level, not the connection level. The mesh does this well, and that is actually a benefit.
I try the mesh first in one non-critical namespace, with a clear goal (mTLS, for example), and measure the latency difference per service.
Sign up to mark studied questions and save your progress.