Course contentsShow
← System Design
Lesson 848 of 1,91922. Service MeshFree lesson

Traffic Management and Routing

Control request routing with canary deployments, A/B testing, and traffic splitting based on headers or weights.

Traffic Management and Routing

What you'll learn: How service meshes enable advanced traffic control like canary deployments, A/B testing, and intelligent routing without changing application code.


The Core Idea

Traffic management lets you control where requests go after they enter your service mesh. Instead of simple round-robin load balancing, you can route requests based on rules: send 10% of traffic to a new version (canary), route mobile users differently (A/B testing), or split traffic by HTTP headers, user identity, or custom weights.

Think of it like a smart traffic controller at an airport: instead of planes landing on any available runway, you direct specific flights to specific runways based on airline, aircraft type, or time of day.

How It Works

The data plane (your sidecar proxies, like Envoy) intercepts all service-to-service requests. The control plane pushes routing rules to these proxies: "Send 95% of requests to v1 and 5% to v2" or "If header user-type: premium exists, route to premium-service."

Canary deployments gradually shift traffic to a new version. Start with 5%, monitor errors and latency, then increase to 25%, 50%, 100% — or roll back instantly if issues arise.

A/B testing routes different user segments to different service versions to compare behavior or performance.

Header-based routing lets you route based on metadata: send requests from your mobile app to api-v2, while web traffic stays on api-v1.

All of this happens transparently — your application code doesn't need routing logic or deployment awareness.

Why It Matters

Service meshes decouple traffic control from application logic. You gain safe, gradual rollouts, experimentation capabilities, and fine-grained control without redeploying services or embedding complex routing libraries.

Key Takeaway:
Traffic management in service meshes enables canary deployments, A/B testing, and header/weight-based routing through declarative rules in the control plane, allowing safe, flexible request routing without application code changes.