Scrivio Interview library
LeadershipAdvanced6 min read · updated 12 November 2026

You are setting the garbage collector standard for about 400 JVM services. What is the default, what exceptions do you allow, and how do you validate a change across the fleet?

The default for all 400 services is the JDK default, G1, with the heap set as a percentage of the container limit and no other GC flags. Allowed exceptions are generational ZGC for latency-sensitive or large-heap services, backed by measurements, Serial for tiny sidecars and tools, and Parallel for batch jobs where throughput is the goal. Copied flag lists are forbidden without a written reason, flags are reviewed on every JDK upgrade, changes roll out through canaries that compare pause distribution, GC CPU, allocation stalls and request latency, and GC metrics from every service are collected in one place so decisions are based on data.

Why this question is asked

In a large fleet, GC configuration tends to drift. Teams copy flags from a blog post, from another service, or from a JDK 8 deployment ten years ago, and nobody remembers why they are there. Some of those flags hurt performance on modern JDKs; some break on upgrade. A standard is how a platform team turns this into something simple, measurable and safe to change. Interviewers ask this to see whether we can set policy that works for many teams, not just tune one JVM. In this answer, we will look at why a standard is needed, define the default and the exceptions, see how to handle legacy flags, and design a validation and rollout process.

1Why a Fleet Needs a GC Standard

Each JVM flag is a small decision someone made once, for one workload, on one JDK. Copied across 400 services, those decisions stop matching reality. A typical inventory finds -XX:+UseConcMarkSweepGC, a collector that was removed in JDK 14, so newer JDKs ignore the flag with a warning or, once it expires, refuse it as an unrecognized option. It finds -Xmn set on G1, which quietly disables G1's pause-time adaptation. And it finds NewRatio, SurvivorRatio or ParallelGCThreads values that were tuned for hardware that is long gone.

The goal of the standard is the opposite: a small default that the JDK tunes for us, a short list of exceptions with clear reasons, and data that tells us when an exception is earning its place.

2The Default

The default is the JDK's own default collector, G1, with only one setting: the heap as a percentage of the container memory limit, so heap sizes scale with how the service is deployed. Everything else is left to ergonomics.

Java
# fleet default flags, set once in the shared base image (comments are for the reader)
-XX:MaxRAMPercentage=70 # heap = 70% of the container limit; the rest for metaspace, threads, buffers
-Xlog:gc*:file=/logs/gc.log:time,uptime,level,tags:filecount=5,filesize=20m
# no other GC flags

The reasons are practical. G1 is what the OpenJDK developers tune and test most, so each JDK upgrade improves it for free. A single setting means there is nothing to get wrong. And since the base image sets it, teams get the default without doing anything. We also set -XX:+UseG1GC explicitly in the base image, so that very small pods do not silently drop to Serial; sidecars that want Serial opt in, as the exceptions below allow.

The exact percentage is a judgement: 70 to 75 percent works for most services, while services with heavy off-heap use, such as Netty direct buffers, may need less.

3The Allowed Exceptions

Exceptions exist because one collector does not fit every workload. Each one has a condition and evidence attached.

Fleet GC policy
OptionAllowed whenEvidence required
G1, heap % onlyalways: the defaultnone
Generational ZGClatency target G1 cannot hold, or large heapcanary: tail latency, GC CPU, stalls
Serialsidecars and tools, 1 CPU, small heapnone beyond size
Parallelbatch jobs judged on total runtimeruntime comparison against G1
Any extra tuning flagwritten reason, owner, review datebefore and after measurements

Teams request an exception by filing a short form in the service repository: the collector, the reason, and measurements from a canary. The platform reviews it once, and it is listed in a central registry so we always know which services deviate.

4Handling Copied and Legacy Flags

The rule is simple: no GC flag without a written reason. A CI check can enforce it by comparing each service's JVM options against the allowed list and failing when an unlisted flag appears without a matching entry in the exception registry.

Legacy flags are removed in a controlled way, not all at once. For each service, we run a canary with the flags removed and compare it against the current configuration over a few days of real traffic. In most cases the result is the same or better, because modern G1 makes better choices than a hand-tuned value from years ago, and the flags go. If a flag genuinely helps, it moves into the registry with its measurements.

Flags are also reviewed on every JDK upgrade. Flags are deprecated and removed over time; CMS is gone since JDK 14, non-generational ZGC since JDK 24. The upgrade checklist includes running each service with its flags on the new JDK and checking startup warnings.

5Validating Changes Across the Fleet

Any change to the standard, such as moving to a new JDK, changing the heap percentage, or moving a class of services to ZGC, rolls out through canaries. A small share of instances of each service gets the new configuration while the rest stay on the old one, so both see the same traffic at the same time.

Step throughRolling out a GC change
  1. Propose changewith expected effect
  2. Canary 5% of instancesper service, same traffic
  3. Compare pauses, GC CPU, stalls, latencyfor several days
  4. Any service worse than threshold?
    YesStop for that service and investigateNoWiden to 25%, then 100%
  5. Record result in the registry

5 steps in order. Play them, or step through them one at a time.

We compare four signals per service: pause time distribution, especially p99 and max rather than averages; GC CPU as a share of total; allocation stalls for ZGC services; and request latency at p99 and p99.9 together with error rates. If any service gets worse beyond a set threshold, the rollout stops for that service and someone looks at it.

All this only works if GC data is collected in one place. Every service exports the same GC metrics, from the GarbageCollectorMXBeans through Micrometer or a JVM agent, plus GC logs shipped to central storage. Then we can answer fleet questions with data: how many services run near their heap limit, which ones have pauses above 100 ms, which ones would benefit from ZGC.

6Follow-up questions

How would you handle a team that refuses to remove legacy GC flags?

I would start by asking what the flags are for, because sometimes there is a real reason nobody wrote down. Then I would propose an experiment rather than an argument: a canary with the flags removed, measured against the current configuration on their own traffic, with rollback ready. If the canary is as good or better, the data usually settles it. If it is worse, the flags become a documented exception with an owner and a review date. If the team still refuses without data, the standard's CI check applies to them like everyone else, and I would escalate as a policy question rather than a technical one.

Why not let each team tune its own GC?

Because most teams do not have the time or data to do it well, and the result is drift. A good default plus a cheap exception process gives teams who really need tuning a path, while everyone else gets the JDK's improvements automatically. The platform team's job is to make the default good and the exceptions visible.

Should the heap percentage differ between services?

Only with a reason. The default should suit most services, and a service with large off-heap use, such as heavy direct buffers or a native library, may need a lower percentage. That is an exception with a reason, like any other.

7Conclusion

In this answer, we set a GC standard for 400 services. The default is G1 with the heap set as a percentage of the container limit and no other flags. Generational ZGC is allowed for latency-sensitive or large-heap services with measurements, Serial for tiny sidecars and tools, and Parallel for batch jobs. Copied flags need a written reason, flags are reviewed on every JDK upgrade, changes roll out through canaries comparing pause distribution, GC CPU, allocation stalls and latency, and GC metrics from all services are collected centrally so the standard rests on data.

What to say in the interviewAbout 90 seconds aloud

Open with

I would make the default the JDK default, G1, with one setting: the heap as a percentage of the container limit, say MaxRAMPercentage of 70, and no other GC flags, all set in the shared base image along with GC logging.

Then, if they want more

That way every JDK upgrade improves the fleet without anyone touching configuration. Then a short list of exceptions, each with a condition. Generational ZGC for services whose latency target G1 cannot hold or that have very large heaps, backed by canary measurements. Serial for tiny sidecars and tools. Parallel for batch jobs where only total runtime matters.

Anything else needs a written reason, an owner and a review date, and a CI check rejects GC flags that are not on the allowed list or in the exception registry.

Legacy flags I would remove service by service through canaries, because modern G1 usually beats hand tuning from years ago, and I would review all flags on every JDK upgrade, since collectors and flags get removed.

Any change to the standard rolls out through canaries, comparing pause distribution, GC CPU, allocation stalls and request latency at p99 and p99.9, and stops for any service that regresses. None of this works without central data, so every service exports the same GC metrics and ships its GC logs to one place.

About this answer

Last updated
12 November 2026
Versions it names
Java 14, Java 24, Java 8
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "You are setting the garbage collector standard for about 400 JVM services. What is the...": https://scrivio-interview-library.netlify.app/java/garbage-collection/891b8f67ce/