advanced27 min studyLesson 445 in Engineering

Network sharing: shape traffic and authorize reachability

Analyze aggregate tenant traffic envelopes while keeping bandwidth controls separate from NetworkPolicy, encryption, and application authorization.

On this page

What you’ll understand

  • Convert link-rate units and calculate a hypothetical burst-drain bound.
  • Separate per-flow controls from aggregate per-tenant accounting.
  • Scope Kubernetes NetworkPolicy and Linux traffic shaping to their actual mechanisms.

A retrieval tenant can open many connections, send a large response burst, and dominate a shared egress path without crossing any forbidden network address. Conversely, a tenant can stay within a bandwidth budget while reaching a service it should never contact. Network performance and network authority are separate claims. This lesson uses iproute2 6.12 HTB terminology and Kubernetes 1.34 NetworkPolicy semantics, with hypothetical token budgets that illustrate accounting rather than prescribing a production queue configuration.

Define the tenant aggregate at the enforcement point

A per-connection limit is not a tenant limit when the tenant can create more connections. Choose a trusted aggregate identity and map its traffic into the enforcement domain across workers, namespaces, and gateways. Account for ingress and egress separately, including replication, storage calls, and retries that a user-facing response counter misses. A shared service can also send traffic on a tenant’s behalf, so classification must survive that hop. Otherwise one tenant moves its consumption into a common service account and escapes the intended budget.

Shaping delays eligible traffic until its schedule permits transmission; policing typically enforces an envelope through decisions such as dropping or marking excess traffic. Linux HTB uses hierarchical classes with rate, ceiling, and burst semantics. A configured rate is meaningful within that hierarchy and the actual bottleneck path, not a guarantee that a remote receiver or congested network will supply the same useful throughput. Queue limits, offloads, encapsulation, classification, and the physical interface can change what packet-level and application-level measurements observe.

A(Δt)≤b+rΔtA(\Delta t)\le b+r\Delta t
This ideal token-bucket envelope counts admitted bytes A over an interval of duration Δt≥0 seconds, with nonnegative burst capacity b bytes and sustained rate r bytes per second. It assumes a correctly enforced aggregate bucket; it is not a complete description of every HTB class, packetization effect, or remote path.↔ Scroll wide equations horizontally.

Burst behavior remains even below the average rate

A tenant can have a long-run average below its ceiling and still inject enough work to cause a queue. Size the burst allowance, buffer policy, and deadline response together. A large queue can preserve bytes while making requests uselessly late; a deliberate reject or drop may better preserve a stated service objective, but its cost must appear in reported results. In an inference platform, concurrent completions can synchronize response bursts even if request arrivals looked smooth. Measure the bytes that the downstream path actually carries, including protocol overhead when relevant.

Kubernetes NetworkPolicy describes allowed connectivity at supported network layers when the cluster networking implementation enforces it. It does not itself allocate a bandwidth reservation, encrypt a payload, or validate a customer’s application-level object permission. Policies are additive and plugin behavior matters, including supported protocols and packet processing details. Verify the deployed enforcement path rather than assume that an API object alone isolates traffic. A connection permitted by policy can still carry an unauthorized application operation unless the receiving service checks authority.

texcess≥max⁡(0,D−b)r(r>0)t_{\rm excess}\ge\frac{\max(0,D-b)}{r}\qquad(r>0)
For a simplified initially full bucket and queued burst D bytes, this is a seconds-valued lower bound on waiting to admit bytes beyond burst allowance b at refill rate r. It ignores packetization, physical serialization, other traffic, and drops; it is not an end-to-end response-time formula.↔ Scroll wide equations horizontally.

Measure sharing without confusing it with reachability

Run a fixed victim request mix while varying an authorized aggressor’s connection count, packet sizes, response sizes, and direction. Observe offered bytes, admitted bytes, retransmissions, drops, queue delay, and deadline goodput, then repeat at the actual constrained hop. A test inside a fast virtual interface may miss the shared external bottleneck entirely. Separately test forbidden source/destination combinations and application tenant checks. Passing one performance benchmark gives no evidence that a missing NetworkPolicy or an overly broad service credential is safe.

Reset the queue lab, explicitly set arrival two and service three, predict the initial four-item backlog shrinking, then Play or Step. For a distinct overload run Reset and explicitly set arrival four and service three before predicting again. These are fixed-rate abstract jobs, not packets with lengths or token buckets. Control edits retain elapsed time and recompute the initial-value formula. Use the lab to reason about offered versus served work, then use packet and application evidence to test shaping and authorization on the real path.

A safe average does not erase a synchronized burst

A hypothetical aggregate bucket refills at 100 megabits per second, uses decimal units, and initially holds five megabytes. One hundred responses of 250 kilobytes arrive together. Later the steady response rate is 40 per second. Calculate the ideal excess-admission time and steady byte rate.

  1. Convert 100 megabits per second to 12.5 megabytes per second by dividing by eight. The synchronized responses contain 100 times 0.25 megabytes, or 25 megabytes, before any protocol overhead.

  2. The initially full five-megabyte bucket can cover five megabytes immediately in this admission abstraction. Twenty megabytes remain, requiring at least 20/12.5, or 1.6 seconds, of refill time if queued and admitted without any other competing traffic.

  3. The later steady rate is 40 times 0.25, or ten megabytes per second, below the refill rate. This does not undo the earlier burst delay, and actual packet transmission still consumes link time. Drops, other traffic, and overhead can change observed outcomes.

The result

A below-ceiling long-run average and a burst-induced deadline failure can coexist. Report both the byte envelope and useful delivery behavior.

Explore the model

Interactive lab

Interactive lab · queue

Offered and served work are only a network-pressure analogy

For fresh runs use Reset → explicitly set BOTH rates → predict → Play/Step. Compare (λ,μ)=(2,3) with Reset plus (4,3), each from q=4. There are no packets, byte lengths, token buckets, policies, or network hops in the model.

Offered and served work are only a network-pressure analogyFluid backlog starts at 4 and follows max(0, 4 + (λ − μ)t). The separate M/M/1 residence-time formula assumes Poisson arrivals, exponential service and λ < μ. Current readings: Fluid backlog: 4; Net rate · λ − μ: −1 /s; M/M/1 mean residence: 1 s. All parameters are adjustable with the labeled controls below.02.557.51001.534.56Elapsed time · sFluid backlogλ < μ
Fluid backlogCurrent time
Fluid backlog
4
Net rate · λ − μ
−1 /s
M/M/1 mean residence
1 s
t = 0 s

Fluid backlog starts at 4 and follows max(0, 4 + (λ − μ)t). The separate M/M/1 residence-time formula assumes Poisson arrivals, exponential service and λ < μ. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.

Look forAverage queue pressure helps frame a test but does not simulate HTB or NetworkPolicy.

Check your understanding

Which statement correctly separates Kubernetes 1.34 NetworkPolicy from bandwidth shaping?

Try it yourself

A hypothetical aggregate bucket refills at 80 megabits per second and initially holds two decimal megabytes. A ten-megabyte burst arrives. Calculate the ideal refill time needed beyond the initial allowance. What changes if ten separate connections each get the full bucket?

Take a moment to make a prediction or work it out on paper. Open a hint when you need one.

Give me a hint

Convert bits to bytes and distinguish one aggregate envelope from ten independently granted envelopes.

Compare with the solution

The rate is ten megabytes per second. Eight megabytes exceed the initial allowance, giving a lower bound of 0.8 seconds to admit the excess under the stated queue-and-refill model. Ten independent full buckets could collectively allow 20 megabytes of initial burst and a combined nominal refill of 100 megabytes per second. That violates the intended single-tenant envelope unless another aggregate control applies. Neither construction tests whether the destination or requested object is authorized; validate those boundaries separately.

Take it with you

  • Aggregate traffic under a trusted tenant identity rather than an arbitrary flow count.
  • Burst allowance and queueing policy affect deadlines even below the average ceiling.
  • Reachability, bandwidth, encryption, and application authority are distinct controls.

Read further

Original sources and deeper explanations to follow at your own pace.

Optional progress, saved in this browser when available. Revisit any lesson at any time.

Lesson not marked complete.