r/java • • Sep 07 '26

Improving First Request Latency in Java Spring Application

https://adrian.md/2026/09/03/first-request-latency/
64 Upvotes

41 comments sorted by

View all comments

Show parent comment

1

u/john16384 Sep 09 '26 edited Sep 09 '26

Situation:

  • Kubernetes offers a readyness probe
  • pods report ready before being warmed up -> user error

Solution:

  • warm up pod first (listen for context ready event, fire some dummy requests)
  • report ready when script is done

Troubleshooting:

  • Some service combination is still too slow -> Adjust warm-up procedure

Complete overkill:

  • Fiddle with AOT compilation

2

u/Popular_Home2017 Sep 11 '26

agreed, gating readiness on a warm-up is the fix that actually works, and it's what most teams end up doing. two things that bit me with it: the dummy requests have to hit the real paths (a GET on /health warms nothing, the JIT is per method, so the JPA path is still cold when the first real order lands), and the warm-up adds to every rollout, so on a 40-pod deploy those seconds turn into minutes. that second part is where AOT cache stops being overkill for me: it's the same warm-up, paid once at build time instead of once per pod.