Skip to content

Measurement and Performance

Core Idea

Examples and diagrams in this page follow the shared Hypothetical Scenario.

Performance engineering is a measurement discipline. No credible optimization plan starts from intuition alone. Teams need explicit latency and throughput targets, reliable baseline data, and repeatable profiling workflows. Without this foundation, tuning work becomes local guesswork that increases complexity with uncertain benefit.

In the scenario platform, users evaluate vehicles by reliability, ownership cost, and marketplace availability. Perceived responsiveness directly affects trust. If recommendation queries are fast but profile updates stall, user confidence drops. Performance strategy must cover full journeys, not isolated endpoints.

Conceptual Overview

Performance Model and Capacity Model

A rigorous performance program distinguishes two related models.

  1. Performance model This model explains latency contributors in one request path. It tracks service time, queue wait, network overhead, serialization cost, and downstream fan-out.

  2. Capacity model This model explains how throughput changes under load. It tracks concurrency limits, saturation points, and scaling thresholds.

Both models are required for architecture planning. Latency tuning with no capacity model can hide collapse risk at peak load. Capacity tuning with no latency model can satisfy volume targets and still violate user experience goals.

Metrics That Matter

Mature teams avoid single averages as primary indicators. Average latency hides tail behavior. Tail latency drives user pain and incident volume in distributed systems.

Core metrics for the scenario:

  • p50, p95, and p99 latency by use case
  • request throughput by operation type
  • saturation indicators for CPU, memory, disk, and queue depth
  • error rate partitioned by class and dependency
  • cache hit ratio by contract capability
  • downstream fan-out count per request

This set supports both diagnosis and architectural decisions.

Little's Law and Queue Awareness

Little's Law provides a practical frame for service capacity. For stable systems, average items in system equals arrival rate multiplied by average time in system. The implication is direct. As response time grows, concurrency pressure grows. As concurrency pressure grows, queueing delay increases. This feedback loop can destabilize services if admission control is weak.

Architecture teams should treat queue depth and wait time as first-class signals. This applies to request queues and message brokers. It links performance and resilience work.

Experiment Design and Benchmark Hygiene

Benchmark results are useful only with controlled context. Teams should record dataset shape, warm-up method, hardware profile, and dependency conditions. Cold cache and warm cache runs should be reported separately. Variance should be tracked through repeated runs.

A practical workflow:

  • define a hypothesis with one expected measurable change
  • run baseline with fixed load profile
  • apply one change
  • rerun under same profile
  • compare distribution, not only mean
  • keep results in versioned performance records

This workflow prevents accidental metric cherry-picking.

Performance and Architecture Boundaries

Performance decisions can violate clean architecture if applied without boundary discipline. Teams often place caching and pooling logic inside domain classes. That short-term shortcut increases long-term coupling.

A better model keeps performance mechanisms in adapters and infrastructure boundaries. Domain logic should express policy. Outer layers should implement storage, transport, and caching strategy. This keeps design options open across REST, GraphQL, gRPC, and messaging channels.

Computing History

Donald Knuth warned against premature optimization in 1974. The warning was not anti-performance advice. It was a warning against cost without evidence. Amdahl had already shown in 1967 that speedup is bounded by the serial fraction of a workload. Together these ideas shaped modern performance engineering as a data-first discipline.

Sources: Knuth (1974) and Amdahl (1967)

Quote

"Premature optimization is the root of all evil."

Source: Donald E. Knuth, 1974

Practice Checklist

  • Define latency and throughput objectives for each critical user journey.
  • Track percentile latency, not only average response times.
  • Establish baselines before tuning and retain baseline artifacts.
  • Profile production-like workloads with realistic dataset distributions.
  • Record warm-up, cache state, and dependency behavior in benchmark reports.
  • Prioritize bottlenecks by measured impact and user-facing risk.
  • Separate domain logic from caching and transport performance mechanisms.
  • Add capacity tests that expose queue growth and saturation boundaries.
  • Review p95 and p99 regressions in release readiness checks.
  • Keep a performance decision log with measured trade-offs.

Written by: Pedro Guzmán

See References for complete APA-style bibliographic entries used on this page.