Traffic Splitting: Route Live Traffic Between Service Versions

Traffic splitting directs percentages of live user traffic to different versions of a service. It's key for canary releases, letting you test new code on a small user group before a full rollout.
Why it exists
Deploying new code to 100% of users at once is a high-stakes gamble. A single bug can cause a site-wide outage. Traffic splitting was created to de-risk deployments by allowing developers to expose new code to a small, controlled subset of live traffic first, limiting the blast radius of any potential issues.
The mental model
Traffic splitting is a programmable traffic controller for your services. Instead of a coarse, slow-to-propagate DNS change, a service mesh or ingress controller makes routing decisions on a per-request basis. It's like a highway traffic controller who can be told, "Send 99% of cars down the main highway, but divert 1% onto this newly paved test lane."
How it works
In a Kubernetes environment, you run multiple deployments of the same application, distinguished by labels (e.g., version: v1 and version: v2). A service mesh proxy (like Envoy in Istio) or an ingress controller intercepts all requests. You define a rule, such as an Istio VirtualService, that specifies the weighting: "For requests to the reviews-service, send 90% of traffic to pods with label version: v1 and 10% to pods with version: v2." The proxy enforces this rule for each incoming request.
When to use it
The three main use cases are: first, Canary Releases, where you slowly increase traffic to a new version (1%, 5%, 25%, 100%) while monitoring metrics. Second, A/B Testing, where you route specific user segments (e.g., users with a certain cookie or header) to a different version to compare behavior. Third, Blue-Green Deployments, where you shift 100% of traffic from the old "blue" version to the new "green" version instantly after verification.
When not to use it
Avoid simple percentage-based splitting for stateful applications unless you also configure session affinity (sticky sessions). If a user's multi-step workflow depends on server-side state, bouncing them between v1 and v2 can corrupt their session and break the user experience. It is also overkill for simple apps in non-critical environments where a brief downtime for a standard rollout is acceptable.
One canonical example
You have a payments service and deploy a new version, payments:v2. You configure your service mesh to send 99% of traffic to the stable payments:v1 and only 1% to v2. You watch your dashboards for v2's error rates and latency. If metrics are healthy, you update the rule to 90/10, then 50/50, and finally 0/100 to complete the rollout safely.
Interview question
What is the primary benefit of using traffic splitting for deploying new service versions?
- a.To eliminate the need for separate staging or testing environments.
- b.To ensure all users receive the latest features simultaneously.
- c.To minimize the impact of potential issues by gradually exposing new code to live traffic.Correct
- d.To simplify the process of managing session state for stateful applications.
Why? this is the answer
The card highlights that traffic splitting was created to "de-risk deployments by allowing developers to expose new code to a small, controlled subset of live traffic first, limiting the blast radius of any potential issues." Option D is incorrect because the card explicitly warns against using simple percentage-based splitting for stateful applications without also configuring session affinity.
Just read this? Test yourself on what you have been reading.
Read the original → istio.io
- #kubernetes
- #service mesh
- #istio
- #deployment patterns
Put your scrolling time to good use
Learn one idea, try a quiz and save useful cards for revision. Tezvyn makes it easy to learn and stay current in your tech field, a few minutes at a time.
The iPhone app is on the way
We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.
Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.
We are hiring for this. Open roles that interview on kubernetes — each one lists the topics its interview covers.
See open roles