advanced24 min studyLesson 380 in Engineering

Proxy cost: measure useful operations, attempts, and critical paths

Attribute latency, CPU, memory, and connection work to a defined boundary while avoiding double-counted spans and misleading benchmark comparisons.

On this page

What you’ll understand

  • Distinguish operation-level latency from attempt and connection metrics.
  • Calculate CPU demand using a stated attempt rate and per-attempt boundary.
  • Design a matched measurement that includes queueing, failures, and resource saturation.

A proxy adds processing and can also change connection reuse, retries, security work, and routing. Comparing two latency numbers without matching those behaviors answers an unclear question. Define useful operations, attempted work, the critical-path timing boundary, and allocated resources before deciding whether an intermediary's capabilities justify its measured cost.

Use compatible populations and timing boundaries

The client observes a logical operation that may include local waiting, retries, network time, and application execution. A proxy's upstream-attempt duration is a different population and interval. An inclusive proxy span can overlap application work, so adding it to an inclusive application span can double-count time. Use a trace with compatible clocks or explicitly measured local durations to identify the critical path. Do not add component p99 values and call their sum the operation p99; quantiles do not generally compose that way.

Compare completed useful operations, attempted backend requests, failures, cancellations, and rejected admission together. Lower latency among the few accepted successes can hide extensive rejection. A closed-loop test client that waits before issuing its next request can reduce offered load during a slowdown, obscuring queueing that a production arrival process would create. Document offered versus achieved rate and the load-generation method. Also keep request size, protocol, streaming duration, connection reuse, and TLS handshake frequency comparable when estimating the effect of adding a proxy.

L=λWL=\lambda W
Little's law relates long-run average in-system population L, admitted throughput λ in items per second, and average residence W in seconds for a stable consistently defined system. Use either operations or attempts throughout, account for departures including failures, and do not substitute a latency percentile for W.↔ Scroll wide equations horizontally.

Count CPU, memory, and connections separately

CPU seconds per second measures processor demand, not elapsed latency. Per-attempt processing includes a different cost boundary from per-connection handshakes and persistent background work; measure or amortize them explicitly. More retries can raise CPU demand without changing the original operation rate. Encryption and parsing costs depend on bytes and protocol features, while telemetry filters can add work and memory. A single requests-per-second number cannot describe an AI inference stream whose output sizes and lifetimes vary widely across requests.

Memory includes connection state, stream buffers, configuration, certificate material, telemetry queues, and allocator retention. Per-proxy idle memory multiplied by a fleet count is not a loaded-memory estimate. A node-local proxy can share some overhead while concentrating many workloads and creating a different contention boundary. Container CPU quotas and throttling can introduce long delays even when average utilization seems moderate. Measure both the resource limits available to the process and the node conditions around it, including application competition and network scheduling.

Cattempts=λoperations Aˉ (csource+cdestination)C_{\rm attempts}=\lambda_{\rm operations}\,\bar{A}\,(c_{\rm source}+c_{\rm destination})
λ_operations is original operations per second, A-bar is mean backend attempts per operation, and c terms are measured incremental CPU seconds per attempt at two specified stages traversed by every attempt. The result is CPU seconds per second; background, per-connection, and other paths are excluded unless explicitly included in those costs.↔ Scroll wide equations horizontally.

Attribute a bottleneck before extrapolating

Run a matched baseline with identical application behavior and then add the selected proxy policy features in controlled steps. Separate steady reused connections from connection churn, and compare small messages with realistic payloads. Record CPU profiles, throttling, active streams, queued requests, buffer use, retransmissions, and useful completion rate. Repeat representative loads around the saturation point. A configuration that is inexpensive at low utilization can create a queue under a burst, while removing a policy feature can change security or retry semantics and invalidate an apparently faster comparison.

The queue lab isolates a specific queueing assumption. Reset, set λ=2 and μ=3, predict the separately labeled M/M/1 mean residence time is one second, then Play or Step; the fluid initial backlog drains in four seconds. Separately Reset, set λ=2.50 and μ=3, predict M/M/1 mean two seconds and fluid drainage eight seconds, then Play or Step. The stochastic mean assumes Poisson arrivals, independent exponential service, one server, and stability. It is not a measured proxy p99, and the fluid path is a different deterministic model. Explain both boundaries before applying queueing intuition to actual telemetry.

Account for attempts at two proxy stages

A fictional service processes 2,000 original operations/s with mean 1.25 backend attempts each. Every attempt traverses two proxy stages whose measured incremental CPU costs are 40 and 60 microseconds per attempt. Exclude handshakes and background work.

  1. Backend attempt rate is 2,000×1.25=2,500 attempts/s. Use this population for both stage costs because the example explicitly sends every attempt through both stages.

  2. Combined incremental CPU cost is 40+60=100 microseconds, or 0.0001 CPU seconds per attempt. Demand is 2,500×0.0001=0.25 CPU seconds per second.

  3. This quarter-core accounting is not 0.25 seconds of added request latency and excludes the stated other work. Measure critical-path elapsed time, resource limits, and successful operations separately.

The result

The specified attempt-processing boundary consumes a modeled quarter core. Retrying less can change that work, but changing semantics or measurement boundaries must remain visible.

Explore the model

Interactive lab

Interactive lab · queue

A queueing mean is not a proxy latency percentile

Reset, set λ=2 and μ=3, predict M/M/1 mean residence 1 s and fluid drainage 4 s, then Play or Step. Separately Reset, set λ=2.50 and μ=3, predict mean 2 s and drainage 8 s, then Play or Step. The labeled stochastic formula needs its M/M/1 assumptions; neither model measures proxy CPU or p99 latency.

A queueing mean is not a proxy latency percentileFluid 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 forRates, averages, deterministic backlog, CPU demand, and latency percentiles require matching definitions.

Check your understanding

Why is adding a proxy's inclusive p99 span to an application's inclusive p99 span generally invalid?

Try it yourself

A stable measured attempt population has throughput 400 attempts/s and mean residence 0.05 s within a specified proxy boundary. Find average in-system population. Explain why substituting a 0.2 s p99 would answer the wrong question.

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

Give me a hint

Little's law uses a mean over a consistently defined population.

Compare with the solution

Average population is 400×0.05=20 attempts. Multiplying throughput by a 0.2 s p99 would give 80, but that is not Little's-law average population because a percentile is not the required mean. Failures, cancellations, and admission boundaries must also be counted consistently in the measured throughput and residence.

Take it with you

  • Measure operations, attempts, and connections as separate populations.
  • Avoid overlap and percentile addition when attributing elapsed latency.
  • Resource demand and queueing evidence need matched workload and measurement boundaries.

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.