Video in progress
What do you understand by a stop-the-world pause?
The time during which the JVM stops all application threads in order to do part of the GC's work. During this time requests don't get answered, so the length of the pause directly affects latency.
📖 Answer
If application threads also change objects while the GC is moving them or updating references, you get confusion. The simplest solution is to stop everyone. The threads stop at a safe point (safepoint), the GC does its work, and then everything continues.
How the user notices it:
- a REST endpoint usually responds in 20 ms but sometimes takes 800 ms: those are the requests that happened to hit a GC pause;
- a health check times out and Kubernetes restarts the pod;
- a Kafka consumer's session expires and a rebalance starts.
GCs reduce the pause in different ways. Serial and Parallel do all the work inside the pause. G1 does a lot of the work in parallel with the application (concurrently) and tunes the pause to a target (200 ms by default). In ZGC and Shenandoah almost everything is concurrent, and pauses are under a millisecond.
To see the pauses, turn on the GC log: -Xlog:gc*:file=gc.log.
Sign up to mark studied questions and save your progress.