Video in progress

In the company there is a proposal: "Java eats a lot of memory, so we'll write new services in Go". How do you evaluate this from the JVM's point of view?

First I measure what "eats a lot" is based on. Often the cause is a badly configured heap, extra frameworks and the container budget, not the language itself. Then I compare the real difference (RSS, CPU, startup, throughput) on the same task, and decide together with the team's skills, the ecosystem and the operational cost.

📖 Answer

In a debate like this there is a lot of feeling and few numbers. I break it into technical questions.

  1. Where is the memory going right now? Many "fat" Java services have:
  • -Xmx set to 75% of the limit and the JVM fills it (G1 likes to use free heap), so that is a reserve, not consumption;
  • 200 platform threads, huge connection pools;
  • needless Spring starters, big caches.

Tuning such a service often cuts RSS by 30-50% without changing the language.

  1. The real difference. Go has a small runtime, AOT compilation, startup in milliseconds, and an idle RSS of 10-30 MB. An empty Spring Boot on the JVM is 150-300 MB. For small services with many copies (sidecars, CLIs, agents) this difference matters. In big business services the working data dominates and the difference shrinks. In CPU and throughput the JVM with C2 is often equal or ahead.

  2. The JVM's own answers. GraalVM native image (startup and RSS close to Go), AOT cache, compact object headers, virtual threads (a model like goroutines). "Native image for small services" is often the middle ground.

  3. Non-technical factors. The team's 40 Java developers, shared libraries, observability, security standards, the domain knowledge in Hibernate/Spring. A second language is a second CI, a second set of libraries, a second on-call knowledge base.

How I decide: prototype one typical service in all the variants (a tuned JVM, native image, Go), measure RSS, CPU per request, p99 and startup under the same load, and then convert that into infrastructure cost. The result is often: Go for sidecars and utilities, business services in Java, but properly tuned. If the savings are less than one developer's salary per year, switching languages isn't justified.