Course contentsShow
← Cloud and Infrastructure
Lesson 1605 of 2,98933. Service Mesh FeaturesFree lesson

Traffic Splitting and Weighted Routing

Implement percentage-based traffic distribution across multiple service versions for gradual rollouts.

Traffic Splitting and Weighted Routing

You'll learn how to distribute incoming traffic across multiple service versions using percentage-based rules, enabling safe, gradual rollouts.

What Is Traffic Splitting?

Traffic splitting (also called weighted routing) lets you send a defined percentage of requests to different versions of the same service. Think of it like a restaurant testing a new menu item: instead of replacing everything overnight, they offer it to 10% of customers first, then gradually increase as confidence builds.

In a service mesh, you define weights that determine what fraction of traffic each version receives. For example, route 95% to your stable v1 and 5% to your new v2. If v2 performs well, gradually shift to 50/50, then 10/90, until v2 handles everything.

How It Works

Using resources you've already seen—VirtualServices and DestinationRules—you specify traffic weights in the VirtualService routing rules. The DestinationRule defines subsets (like v1 and v2) based on labels, and the VirtualService references those subsets with percentage weights.

The service mesh's data plane proxies enforce these weights at runtime, distributing requests according to your rules. This happens transparently to both clients and services—no application code changes needed.

Why Use Weighted Routing?

  • Canary deployments: Test new versions with minimal risk
  • Blue-green transitions: Gradually shift traffic between environments
  • A/B testing: Compare performance or user behavior across versions
  • Rollback safety: Instantly revert percentages if issues arise

Unlike header-based routing (which requires specific request attributes), traffic splitting works on all requests automatically based purely on distribution percentages.

Key Takeaway: Traffic splitting distributes requests across service versions by percentage, enabling controlled, low-risk rollouts where you incrementally increase traffic to new versions while monitoring behavior before full deployment.