Skip to content
tezvyn:
Menu

Traffic Shaping for Safer Deployments

Source: Wikipedia: Traffic shapingMediumHow cards are made

In deployments, traffic shaping isn't about network speed, but controlling user exposure. You route a precise percentage of users to a new code version, slowly 'opening the valve' from 1% to 100% to de-risk the release. This is the engine of a canary deploy.

Why it exists

Traditional 'big bang' deployments are risky, exposing 100% of users to potential bugs at once. The concept of traffic shaping was adapted for deployments to minimize this 'blast radius,' allowing for controlled, gradual rollouts that can be quickly reversed.

The mental model

While network traffic shaping delays packets to manage bandwidth, in deployments it's a metaphor for controlling user flow. Think of it as a weighted routing system or a dimmer switch for your release. You have two versions of a service, and you decide exactly what percentage of users are routed to the new one.

How it works

This is typically managed by a layer 7 proxy, like an API gateway or a service mesh sidecar (e.g., Envoy). A control plane (e.g., Istio, a cloud load balancer) is given a rule like 'send 95% of traffic to service v1 and 5% to service v2.' The proxy intercepts each request, checks the rule, and forwards it to the appropriate service version. Engineers monitor metrics for v2 and adjust the percentage until it safely handles 100% of traffic.

When to use it

It's essential for implementing canary releases, blue-green deployments, and A/B tests for critical, user-facing applications. It allows you to validate performance, correctness, and business metrics on a small subset of real users before committing to a full rollout.

When not to use it

The infrastructure overhead (e.g., a service mesh) may be too high for simple, non-critical internal tools. It's also complex for stateful applications that require careful handling of database migrations and session affinity, as simply splitting traffic can lead to inconsistent user experiences.

One canonical example

A team releases a new version of their API. They configure their API Gateway to route 1% of production traffic to the new version. They watch their observability platform, comparing the error rate and latency of the new version against the old. Seeing no issues, they increase the traffic to 10%. An hour later, an alert fires for increased latency on the new version. They immediately set the traffic percentage for the new version back to 0%, instantly mitigating the issue for all users while they investigate the performance problem offline.

Interview question

What is the primary objective of employing traffic shaping in the context of software deployments?

  • a.To optimize network bandwidth usage and reduce latency for all users.
  • b.To ensure uniform distribution of requests across all available server instances.
  • c.To control the percentage of users exposed to a new code version, enabling gradual rollouts.Correct
  • d.To enforce strict rate limiting on API requests to prevent system overload.
Why?

The card defines traffic shaping in deployments as controlling user exposure to new code versions to de-risk releases through gradual rollouts. Option A describes traditional network traffic shaping, which the card explicitly differentiates.

Just read this? Test yourself on what you have been reading.

Read the original → en.wikipedia.org

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.

Get it on Google PlayiPhone app coming soon

We are hiring for this. Open roles that interview on ci/cd — each one lists the topics its interview covers.

See open roles