Skip to content
hasanyelaldiPublic

About

Static analysis for resilience configuration in microservice graphs. Finds where retry, timeout and circuit-breaker settings (Resilience4j, Istio, Spring) go past safe limits, computed from real config with sourced provenance.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Plimsoll

Every ship has a Plimsoll line. Your service graph should too.

Project page: hasanyelaldi.github.io/plimsoll

Plimsoll finds where retry, timeout and circuit-breaker settings across a service graph go past safe limits. It reads the real configuration (Java code, Spring YAML, Istio manifests), builds the call graph, and reports problems such as a ×27 retry storm three hops down or a retry budget that cannot fit in the caller's deadline.

Every number in a report is computed by deterministic code, and every value it uses says where it came from (file:line or a library's documentation). Reports are meant to be attached to architecture decision records as evidence.

Status: v0.2.0: SARIF output and a GitHub Action, on top of the v0.1 analysis. The CLI works on hand-written specs and on Spring Boot / Spring Cloud / Istio projects; see Known limitations before trusting a report.

Install and run

Requires Java 21. The CLI is one executable jar. Download it from the v0.2.0 release, or from Maven Central:

curl -fLo plimsoll.jar https://repo1.maven.org/maven2/io/github/hasanyelaldi/plimsoll-cli/0.2.0/plimsoll-cli-0.2.0.jar
java -jar plimsoll.jar analyze path/to/spec-or-repo

In GitHub Actions

The repository is also a GitHub Action. It runs plimsoll analyze and uploads the findings to code scanning, where they show up on the configuration lines they came from:

on: [push, pull_request]
jobs:
  plimsoll:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      security-events: write   # to upload to code scanning
    steps:
      - uses: actions/checkout@v7
      - uses: hasanyelaldi/plimsoll@v0.2.0
        with:
          path: .          # a directory of services, or a spec
          fail-on: ERROR   # fail the job on findings this severe, after the upload

The action downloads the jar of its own version from Maven Central and checks its SHA-256 and its signature against the release key in action/ before running it. Inputs: path, version, jar (a local build instead of a download), max-amp, fail-on, upload, category, sarif-file; outputs: sarif-file, exit-code. It runs on Linux and macOS runners.

plimsoll-demo runs the action on the checkout example; its Security tab shows the alerts. upload-sarif logs one warning per result, "Calculated fingerprint … but found existing inconsistent fingerprint value": Plimsoll sets its own fingerprint so that findings sharing a line stay separate alerts, and code scanning keeps it (ADR 0013). The warning is harmless.

The analysis and the collectors are also libraries:

<dependency>
  <groupId>io.github.hasanyelaldi</groupId>
  <artifactId>plimsoll-collectors</artifactId> <!-- or plimsoll-core for the model and rules only -->
  <version>0.2.0</version>
</dependency>

To build from source:

./mvnw -q -DskipTests package
java -jar plimsoll-cli/target/plimsoll.jar analyze examples/checkout.yaml
Usage: plimsoll analyze [-hV] [--fail-on=<severity>] [--format=<format>]
                        [--max-amp=<n>] [--effective=<service>=<file>]...
                        <spec-or-dir>
      <spec-or-dir>          YAML spec file, or a directory of service modules
      --effective=<service>=<file>
                             A dump of what a running service uses: the JSON
                               of its /actuator/configprops, or its sidecar's
                               Envoy config_dump; repeatable, at most one of
                               each per service, directories only.
      --fail-on=<severity>   Exit with 1 if a finding is at least this severe:
                               ERROR, WARN, INFO (default: ERROR).
      --format=<format>      Report format: TEXT, MARKDOWN, SARIF (default:
                               TEXT).
      --max-amp=<n>          A1 amplification limit (default: 10).
Exit code Meaning
0 no finding at or above --fail-on
1 at least one finding at or above --fail-on
2 invalid input

The same input always gives a byte-identical report, so it can be committed and diffed.

--format=SARIF writes SARIF 2.1.0 for GitHub code scanning and other SARIF viewers. Each finding is placed at the first file:line among the values it used, with the other ones as related locations. Paths are relative to the analysed directory, or to the spec's directory (SRCROOT) (ADR 0013).

Two kinds of input

A hand-written spec

A YAML file that describes services and edges directly. Useful for design reviews before any code exists.

# examples/checkout.yaml
services:
  gateway:  { entry: true, deadline: 3s }
  orders:   { deadline: 2s }
  payments: { deadline: 2s }
  ledger:   { deadline: 500ms }
edges:
  - { from: gateway,  to: orders,
      layers: [ { kind: resilience4j, maxAttempts: 3, perTryTimeout: 1s,    backoff: 100ms, jitter: false } ] }
  - { from: orders,   to: payments, idempotent: false,
      layers: [ { kind: istio,        attempts: 2,    perTryTimeout: 800ms, backoff: 25ms,  jitter: true } ] }
  - { from: payments, to: ledger,
      layers: [ { kind: resilience4j, maxAttempts: 3, perTryTimeout: 300ms, backoff: 0ms,   jitter: false } ] }
  • Durations are strings (300ms, 1s). perTryTimeout and overallTimeout also take unlimited.
  • Layer kind is resilience4j (attempts as maxAttempts), istio (attempts, retries only), http-client or generic (totalAttempts). See Attempt counting.
  • A layer also takes perTryTimeout, backoff, multiplier, maxBackoff, jitter, retryOn and overallTimeout; an edge takes operation, idempotent, fanout and choice.
  • retryOn lists the failure classes the layer retries (ADR 0014): not-sent, reset, timeout, status-500, status-502, status-503, status-504, status-5xx-other, status-409, status-429, status-4xx-other, or a status code such as 503. Without it the layer retries every class.
  • Layers are listed outermost first.
  • A layer may have a circuitBreaker with name, position (wraps-all-tries: outside the layer's retry; each-try: inside it), failureRateThreshold (percent), slidingWindowType (count-based or time-based), slidingWindowSize, minimumNumberOfCalls and waitDurationInOpenState (ADR 0015). The report lists breakers after the findings; no rule uses them yet.
  • An absent multiplier means fixed backoff, an absent fanout means 1; any other absent field is UNKNOWN.
  • A service may say external: true for a callee outside the system, such as an LLM provider (ADR 0019). It cannot be an entry or call anything; A1 counts it against the same limit, and A2b skips it unless it has a deadline.
  • choice: <name> marks edges from one service that are alternatives (only one is taken per request, ADR 0012).

A directory of services

java -jar plimsoll-cli/target/plimsoll.jar analyze path/to/repo

Plimsoll finds the service modules and Istio manifests under the directory and collects:

Source What becomes part of the graph
Resilience4j (application.yml, @Retry, @TimeLimiter) retry and timeout layers on edges named in edges-hint.yaml
Spring Cloud Gateway routes to lb:// services become edges, with their Retry filters, response timeouts and CircuitBreaker filters (settings and TimeLimiter from Spring Cloud CircuitBreaker Customizer beans and Resilience4j properties)
HTTP clients WebClient / RestClient / RestTemplate requests to a known service through a @LoadBalanced client become edges; Spring Cloud LoadBalancer retries become a layer; a reactive Spring Cloud CircuitBreaker run around the request adds a breaker layer with its TimeLimiter
Istio VirtualService, DestinationRule, MeshConfig (istio ConfigMap, IstioOperator, Helm meshConfig) retry and timeout layers, including Istio's implicit default retry policy or the mesh's defaultHttpRetryPolicy
Gateway API HTTPRoute with a Service parent the same layer, as Istio converts it (ADR 0018)
Spring AI OpenAI starter (pom.xml, spring.ai.retry.*) an edge to the external service openai with Spring AI's retry layer, for the versions whose chat model retries with Spring AI's RetryTemplate (2.0.0-M1 to M4; later versions use the OpenAI Java SDK, #108) (ADR 0019)
Kubernetes Namespace, workload and Service labels (istio-injection, sidecar.istio.io/inject, istio.io/dataplane-mode, istio.io/use-waypoint) which edges pass a proxy that applies the Istio layer: sidecar, ambient with a waypoint, or none (ADR 0017)

Several repositories are analysed by checking them out side by side under one directory and analysing that directory.

Code does not always say where a request goes or how long a service may work on one request. An optional edges-hint.yaml in a service module fills that in:

service: api-gateway
deadline: 10s                                     # how long the service works on one request
entry: true                                       # overrides the entry rule
methods:
  - method: com.example.CustomersClient#getOwner  # fully qualified class # method name
    to: customers-service
    operation: GET /owners/{id}                   # defaults to Class#method
    idempotent: true                              # UNKNOWN when absent
    fanout: 1                                     # calls per request, UNKNOWN when absent
    client: webclient-loadbalanced                # or restclient
operations:                                       # facts about operations the service calls
  - to: customers-service
    operation: POST /owners
    idempotent: true                              # e.g. a POST protected by an idempotency key

Without a hint, a service's deadline is UNKNOWN (it is never guessed from timeouts), a Spring Cloud Gateway with routes is the entry, and fanout is UNKNOWN. See ADR 0009.

After the findings, a collected report has a Coverage section: the files read per service, the layer kinds searched and found per edge, and the configuration that was not read (config server, profile documents, other config files, unresolved placeholders). A Notes section lists what collectors saw but could not turn into the model.

What actually runs

The repository is not always what runs: a config server, environment variables, Helm values or the mesh's defaults can change a retry count. Save the running service's /actuator/configprops, or its sidecar's Envoy config_dump, and pass them with --effective (ADR 0016); Plimsoll makes no network call:

curl -s http://orders:8080/actuator/configprops > dumps/orders.json   # needs show-values=always, see below
kubectl exec deploy/orders -c istio-proxy -- pilot-agent request GET config_dump > dumps/orders-envoy.json
java -jar plimsoll.jar analyze . --effective orders=dumps/orders.json --effective orders=dumps/orders-envoy.json

Its Resilience4j, Spring Cloud Gateway, LoadBalancer and CircuitBreaker values replace the declared ones, with the dump's line, JSON pointer and the value's origin as evidence. Each value that departs from the declared graph is a PLM-C2 warning, e.g. orders→payments-service layer 1 (spring-cloud-gateway) totalAttempts: declared 2, runs 3. Spring Boot masks configprops values unless management.endpoint.configprops.show-values is always (or when-authorized for an authorized caller); a masked value keeps its declared value and is noted. spring.ai.* values set at run time are compared key by key; they do not replace the declared spring.ai.retry values in the graph yet.

From a config_dump, the routes of the sidecar to outbound services replace the declared Istio layer on the edges from that service, or add one when no manifest put the callee in the mesh. Envoy's own defaults apply where the dump leaves a field out (one retry, a 15 s route timeout, 25 ms back-off), and retriable_status_codes count as conditions, as a status code in a VirtualService's retryOn does. An edge to a callee the dump has no route for keeps its declared layers, with a note.

Example

plimsoll analyze examples/checkout.yaml (exit code 1):

Plimsoll analysis of checkout.yaml

Amplification per service (limit 10)
  gateway   ×1
  ledger    ×27
  orders    ×3
  payments  ×9

Findings
  ERROR  PLM-A1   ledger  ×27 (orders ×3, payments ×9), limit 10
          gateway→orders layer 1 (resilience4j) totalAttempts = 3 [EXPLICIT: checkout.yaml:9 (maxAttempts)]
          orders→payments layer 1 (istio) totalAttempts = 3 [EXPLICIT: checkout.yaml:11 (attempts 2 + 1)]
          payments→ledger layer 1 (resilience4j) totalAttempts = 3 [EXPLICIT: checkout.yaml:13 (maxAttempts)]
  ERROR  PLM-A3   orders→payments  non-idempotent call retried, 3 tries
          orders→payments idempotent = false [EXPLICIT: checkout.yaml:10]
          orders→payments layer 1 (istio) totalAttempts = 3 [EXPLICIT: checkout.yaml:11 (attempts 2 + 1)]
  ...

Coverage
  Source: hand-written spec; every layer is taken as written, nothing was collected

Summary: 2 error, 7 warn, 2 info

All findings, without the evidence lines:

Rule Location Severity Detail
A1 ledger ERROR ×27 (orders ×3, payments ×9), limit 10
A3 orders→payments ERROR non-idempotent call retried, 3 tries
A2a gateway→orders WARN budget 3.2 s > deadline 3 s, 2 of 3 tries fit
A2a orders→payments WARN budget 2.45 s > deadline 2 s, 2 of 3 tries fit
A2b gateway→orders WARN callee deadline 2 s > per-try 1 s
A2b orders→payments WARN callee deadline 2 s > per-try 800 ms
A2b payments→ledger WARN callee deadline 500 ms > per-try 300 ms
A4 payments→ledger WARN zero backoff
A5 gateway→orders→payments→ledger WARN retries on 3 edges of one path
A4 gateway→orders INFO no jitter
A4 payments→ledger INFO no jitter

Runs on real projects, with a hand check of every finding: spring-petclinic-microservices and TrainTicket.

Rules

Rule Checks Severity
PLM-A1 Amplification How many requests one entry request can cause at each service, assuming every try fails and the failure propagates upward. The attempts of an edge's layers multiply; paths through different callers add up; alternatives (choice) take the largest. A cycle reachable from an entry is UNBOUNDED. ERROR above --max-amp
PLM-A2a Retry budget exceeds the caller's deadline Time for all tries and backoffs, k × perTry + Σ backoff, against the caller's deadline; reports how many tries actually fit. With an unknown per-try timeout, the backoff alone is a lower bound: if it already exceeds the deadline, at most k of n tries fit. WARN
PLM-A2b Abandoned work The callee may work longer (its deadline) than the caller waits for one try, so the callee keeps working after the caller gave up. WARN if the edge retries, else INFO
PLM-A3 Retry on a non-idempotent edge A call that is not idempotent (e.g. POST, per RFC 9110) is retried on a failure the callee may have processed. Retried only when the request was not sent: INFO. ERROR
PLM-A4 Backoff hygiene Retries with zero backoff; retries without jitter. WARN; INFO
PLM-A5 Layered retries One edge retried by two or more layers (e.g. Resilience4j and Istio); one path with retries on two or more edges. WARN
PLM-C1 Mechanism detected but not modelled A retry, timeout or breaker mechanism no collector models yet, found by the patterns in kb/detectors/mechanisms.yaml. Only collected directories produce it. WARN
PLM-C2 Declared configuration differs from what runs A setting in a dump of the running environment differs from the one the repository declares (ADR 0016). Read from /actuator/configprops and Envoy config_dump files given with --effective. WARN

Findings are sorted by severity, then rule, then location. A finding that used an UNKNOWN value is computed with what is known, tagged depends-on-unknown, and names the unknown value; nothing is guessed.

Attempt counting

Libraries count differently. Plimsoll normalizes every layer to totalAttempts, which always includes the first call:

Source Field totalAttempts
Resilience4j Retry maxAttempts (includes the first call) maxAttempts
Istio VirtualService retries.attempts (retries only) attempts + 1
Gateway API HTTPRoute, through Istio retry.attempts (retries only; absent is UNKNOWN) attempts + 1
Spring Cloud Gateway Retry filter retries (retries only) retries + 1
Spring Cloud LoadBalancer max-retries-on-same-service-instance, max-retries-on-next-service-instance (same + 1) × (next + 1)
Spring AI 2.x (spring.ai.retry) max-attempts (retries only: passed to maxRetries; default 10, so 11 tries) max-attempts + 1
generic layer totalAttempts as written

These semantics are not taken from documentation alone: oracle tests run the real Resilience4j, Spring Cloud Gateway, Spring Cloud LoadBalancer and Spring AI retry in test scope and count the calls.

Provenance

Every value in a finding carries its source:

Source Meaning Evidence
EXPLICIT written in configuration or code file:line
LIBRARY_DEFAULT the library's default, because nothing was configured library, version, documentation URL
INFERRED a proposal, never used silently (not produced in v0.1) —
UNKNOWN not known; shown as UNKNOWN in the report why it is unknown

Library defaults come from the knowledge base in kb/defaults/, one YAML file per library. Each entry has a source URL and says how it was verified (doc, source, oracle or none). A default with no sourced entry is UNKNOWN, never invented.

Known limitations

v0.1 gives an upper bound from static configuration. Before acting on a report, know that:

  • Fail-close bound. A1 assumes every try fails and every failure propagates, whatever the retry conditions of stacked layers (retryOn, status codes, exceptions), so it can overstate amplification. When every layer into a service has known conditions, the finding adds the figure per failure class at that service (ADR 0014); the severity stays on the bound (#24).
  • Circuit breakers are listed, not used. A breaker in a hand-written spec is listed in the report (ADR 0015); so are a Resilience4j @CircuitBreaker and a gateway route's first CircuitBreaker filter, with settings from Resilience4j properties and the gateway's Spring Cloud CircuitBreaker Customizer beans. No rule reads breakers, so they do not reduce amplification in the report (#22). A gateway breaker's TimeLimiter is a timeout: per try when the breaker is listed after Retry, overall when before it, and no rule reads overall timeouts. A breaker that code runs around a request with a reactive factory's create("id").run(...) is a one-try layer on that request's edge; the blocking CircuitBreakerFactory is detected by PLM-C1, not modelled. A run fallback, which answers a failure instead of passing it on, is noted but not modelled: A1 counts fail-close.
  • Library versions are not matched. Defaults come from one version per library (for example Istio 1.31, Spring Cloud Gateway 5.0); an older project gets those defaults (#51).
  • Fanout is unknown without a hint. In a collected graph A1 counts an edge without fanout as 1 and reports "at least ×n".
  • Not every request becomes an edge. Only requests through a @LoadBalanced client to a known service are edges; plain clients, DiscoveryClient lookups and hosts built by helper methods (#55) are listed as notes. Requests made at startup are counted as per-request edges (#54).
  • Blocking LoadBalancer retries (RestTemplate, RestClient) have UNKNOWN attempts: there is no oracle test for that path yet.
  • Istio: the MeshConfig defaultHttpRetryPolicy is read from manifests only (per-workload proxy configuration and --set flags are not; a dump with --effective shows what runs); when several HTTP routes of a host disagree, the differing fields are UNKNOWN; services are matched on the first label of the host; without data plane labels in the manifests every caller is assumed to have a sidecar; the injector's enableNamespacesByDefault and labels set only in the cluster are not read. A Gateway API HTTPRoute is read as Istio converts it, only for Service parents and only when Istio manifests or data plane labels are there; consumer routes, GRPCRoute, ports and the installed Gateway API version are not modelled.
  • Spring AI: only the OpenAI starter in a Maven pom.xml is read, at the versions whose chat model retries with Spring AI's RetryTemplate; other model starters, later versions (#108) and Gradle builds are notes and stay PLM-C1. The provider edge has UNKNOWN fanout (one model call per tool round), idempotency (unless an operations entry of the hint says it) and per-try timeout. stream() calls are not retried by Spring AI but are counted as if they were.
  • Configuration not read: config server, profile-specific documents, other config files and unresolved placeholders. The Coverage section lists each one it skipped.
  • Large graphs: A5 enumerates simple paths, which grows exponentially on wide graphs.

Open issues labelled later track the rest.

Related work

  • retryamp: the same graph math over a hand-written spec.
  • Mehan and Saluja, arXiv 2608.25403: a retry amplification factor, from a regex-based study of Python code.
  • RPCShield (Uber, SOSP '26): fail-open / fail-close static analysis for Go.
  • WASABI (SOSP '24): LLM-assisted detection of retry bugs inside code.
  • Mendonça, Aderaldo, Cámara and Garlan (ICSA 2020): a PRISM model of Retry and Circuit Breaker, followed by ResilienceBench.

Plimsoll's contribution is not the graph math but the extraction from real configuration, library semantics verified against the real libraries, and provenance on every value.

Decisions

Architecture decisions are recorded in docs/adr/ (MADR format).

License

Apache-2.0, see LICENSE.

About

Static analysis for resilience configuration in microservice graphs. Finds where retry, timeout and circuit-breaker settings (Resilience4j, Istio, Spring) go past safe limits, computed from real config with sourced provenance.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages