Quick revision
The short answer
I would treat the move to ARM as a correctness migration, not just a cost exercise, because ARM's weaker memory ordering can expose latent data races that never appeared on x86. The plan has five parts: find risky code with static analysis and targeted review of shared mutable state, double-checked locking and custom lock-free code; run load, stress and jcstress tests on ARM before cutover; migrate gradually with canaries while comparing error rates and correctness checks; and check that native dependencies and JDK builds support ARM.
What to remember
In this answer, we treated the ARM migration as a correctness change as well as a cost change, because ARM's weaker memory ordering exposes data races that x86 hid. We assessed risk with static analysis and targeted review of shared state, double-checked locking and lock-free code, tested on ARM with load, stress and jcstress tests, rolled out with canaries that compare error rates and correctness checks, and checked native dependencies and JDK builds for ARM support.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
I would treat the move to ARM as a correctness migration, not just a cost exercise, because ARM's weaker memory ordering can expose latent data races that never appeared on x86. The plan has five parts: find risky code with static analysis and targeted review of shared mutable state, double-checked locking and custom lock-free code; run load, stress and jcstress tests on ARM before cutover; migrate gradually with canaries while comparing error rates and correctness checks; and check that native dependencies and JDK builds support ARM.
Background to this question
Moving Java services from x86 to ARM instances can cut compute costs noticeably, and the JVM makes it look easy: the same JAR runs on both. Most services do move without incident. The risk is concentrated in a small amount of code that was never correct but happened to work, plus dependencies that ship native code. An architect is asked this to see whether they can quantify a hidden risk, spend review effort where it matters, and design a rollout that catches problems before customers do. In this answer, we will look at why the risk exists, how to find risky code, how to test on ARM, how to roll out safely, and the non-concurrency issues that also block migrations.
1Why the Move Changes Behaviour
The Java Memory Model defines the same rules on every platform: a thread is only guaranteed to see another thread's write if a happens-before edge, created by locks, volatile, thread start and join, or the concurrency classes, connects them. Code that follows those rules behaves identically on x86 and ARM, because the JVM emits the right barriers for each.
Code that breaks those rules, code with data races, is a different story. x86 hardware keeps stores in order and loads in order, so many reorderings the JMM permits never happen there. ARM performs them. So a race that has been in production for years without a visible symptom on x86 can start producing stale or half-built objects on ARM. The bugs were already there; the new hardware is what makes them show.
2Assessing the Risk Before Moving
The first step is an inventory, ranked by criticality and by how much shared mutable state each service has. Static analysis does the broad sweep: tools such as SpotBugs or Error Prone have checks for inconsistent synchronization, unsafe lazy initialisation and non-volatile double-checked locking. Simple searches find hand-written lock-free code (VarHandle, Unsafe, Atomic field updaters), custom caches and registries, and fields in singletons that are neither final nor volatile.
Then targeted human review goes where the tools point and where the stakes are highest: shared libraries used by many services, caches, connection and session registries, and anything with double-checked locking or lock-free tricks. A shared library is worth reviewing first, because one fix there protects every service that uses it.
| Pattern | Why it is risky on ARM | Usual fix |
|---|---|---|
| Plain field holding a shared object | Reference may be seen before its fields | volatile reference to immutable object |
| Double-checked locking without volatile | Half-constructed instance visible | volatile, holder class, or eager init |
| Custom lock-free structures | Ordering reasoning may rely on x86 | Library class, or jcstress on ARM |
| Plain stop or ready flags | Never seen, or seen before the data | volatile or a latch |
| Mutable objects in concurrent maps | Map is safe, object fields are not | Immutable values or per-object locks |
3Testing on ARM Before Cutover
Three kinds of tests run on ARM hardware before any production traffic moves. Load tests run the service at realistic and peak traffic on ARM instances, comparing latency, throughput, GC behaviour and error rates with x86; they also answer the cost question, because the saving depends on how many ARM instances are needed for the same load. Stress tests target the concurrent parts, such as caches and registries, with many threads and consistency checks on every result. And for shared libraries, jcstress tests check the smallest concurrent interactions millions of times and report forbidden outcomes.
These tests also need to keep running after the migration. Adding ARM runners to CI means new races are caught on the architecture where they show, instead of only on x86 where they hide.
4Migrating Gradually With Canaries
Each service moves in stages. A small canary group of ARM instances takes a few percent of traffic alongside the x86 fleet, and we compare the two groups directly: error rates, latency percentiles, and, most importantly, correctness signals. Correctness signals are things like reconciliation mismatches, checksum failures, unexpected nulls, cache inconsistency counters and business invariants, which catch silent data corruption that error rates miss.
- Review and fix risky codestatic analysis plus targeted review
- Load, stress and jcstress on ARMcompare with x86 baseline
- Canary at 5% of trafficerrors, latency, correctness checks
- Canary matches x86?YesIncrease to 25%, 50%, 100%NoRoll back, investigate
- Keep x86 capacity for a whilethen retire it
5 steps in order. Play them, or step through them one at a time.
If the canary is clean for long enough to cover peak traffic and batch cycles, traffic grows in steps. If anything diverges, traffic moves back to x86, which is why we keep the x86 capacity until the service has been stable on ARM for a while. Services move in order of risk: low-risk, stateless services first to build confidence and tooling, then services with significant shared state after their review is done.
5Dependencies and JDK Builds
Not every migration problem is about memory ordering. Some Java libraries ship native code: compression libraries, crypto providers, database drivers with native parts, profilers and APM agents, image processing. Each needs an ARM build, aarch64, of the right version, or the service fails at startup or falls back to a slow path. The JDK itself must be a supported build for ARM from the vendor we use, and container base images must be multi-architecture. I would build the inventory of native dependencies early, because a missing ARM build can block a service regardless of how clean its concurrency code is.
It also pays to check JVM settings that were tuned for x86, such as heap sizes, GC choice and thread counts, because ARM instances may have different core counts and memory per core.
6Follow-up questions
How do you justify the review cost to the business?
By comparing it with the cost of silent data corruption. Most services need little review, and the effort concentrates on shared libraries and a few critical services. One shared-library fix protects many services. The canary process also turns the remaining risk into measurable signals instead of incidents.
What if a race is found but fixing it is hard?
Keep that service on x86 until it is fixed, and protect the code in the meantime, for example by putting a lock around the risky section. The fix itself should follow the language rules, not depend on x86, because the race is a bug on every platform.
Would you run CI on both architectures permanently?
For services and libraries that run on ARM, yes, at least for the concurrency and stress test suites. Running all unit tests on both may be unnecessary, but concurrency tests on x86 alone miss exactly the reorderings that ARM exposes.
7Conclusion
In this answer, we treated the ARM migration as a correctness change as well as a cost change, because ARM's weaker memory ordering exposes data races that x86 hid. We assessed risk with static analysis and targeted review of shared state, double-checked locking and lock-free code, tested on ARM with load, stress and jcstress tests, rolled out with canaries that compare error rates and correctness checks, and checked native dependencies and JDK builds for ARM support.
Open with
I would treat it as a correctness migration as well as a cost one. Correctly synchronized Java behaves the same on ARM, because the JVM emits the right barriers.
Then, if they want more
But ARM's memory ordering is weaker than x86, so code with data races, which happens to work on x86 because the hardware keeps stores and loads in order, can start showing stale values or half-built objects. Those bugs were always there; x86 hid them. So first I assess the risk.
Static analysis like SpotBugs or Error Prone finds inconsistent synchronization and unsafe lazy initialisation, and searches find custom lock-free code, double-checked locking and shared non-final, non-volatile fields. Then targeted review goes to the riskiest places, shared libraries first, since one fix there protects every service.
Second, I test on ARM before cutover: load tests to compare performance and confirm the cost saving, stress tests on caches and registries with consistency checks, and jcstress for shared libraries, and I add ARM runners to CI so these keep running.
Third, I migrate gradually: low-risk stateless services first, then canaries of a few percent of traffic per service, comparing not only error rates and latency but correctness signals like reconciliation mismatches and invariant checks, which catch silent corruption. I keep x86 capacity to roll back.
And finally I check the non-concurrency blockers early: native libraries and agents need aarch64 builds, the JDK must be a supported ARM build, and container images must be multi-architecture.
About this answer
- Last updated
- 12 November 2026
- 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.
- Official documentation
- JLS chapter 17, Threads and Locks
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 "Your company plans to move most Java services to ARM instances for cost reasons. As the...": https://scrivio-interview-library.netlify.app/java/java-memory-model/7e99c740cc/