---
title: "Performance and resilience"
chapter: "14"
---

# Performance and resilience

Performance is the user experience under expected load. Resilience is useful
behavior when dependencies, instances, or networks fail.

## Measure first

Load-test realistic traffic, payloads, database size, cache state, and failure.
Measure latency percentiles, throughput, errors, CPU, memory, garbage
collection, thread pools, connection pools, queue depth, and dependency time.

## Protect resources

Configure HTTP, database, broker, and executor pools from total instance
capacity. Bound queues. A huge queue hides overload and increases latency.
Use bulkheads so one dependency cannot consume every thread.

## Remote-call policy

Every remote call needs a timeout. Retry only transient and safe operations,
with a small bound, exponential backoff, and jitter. Use circuit breakers to
stop repeated calls during an outage. Provide graceful degradation for
optional features.

## JVM and native choices

Tune only after profiling. Modern JVM ergonomics are strong. Native images can
improve startup and memory for suitable workloads but change build,
reflection/resource configuration, debugging, and peak-throughput trade-offs.

## Feynman check

A timeout is a clock, a retry is another attempt, a circuit breaker closes the
road, and a bulkhead keeps one flooded room from sinking the whole ship.
