- Status: Accepted
- Date: 2026-12-01
- Amends: ADR-0001 (development platform). ADR-0002 and ADR-0003 are unchanged in substance.
- Amended by: ADR-0005, ADR-0006
Amendment (2026-12-02): Consensus now uses Apache Ratis (ADR-0005), which brings its own shaded gRPC/Netty transport for peer traffic. The "no Netty, gRPC" row below now applies to our own networking code, which carries the client protocol. The Raft-specific mitigations below (deterministic Raft simulation, our own WAL with
FileChannel.force) are replaced by the testing and durability plan in ADR-0005. Deployment moved from AWS EC2 to GCP Compute Engine (ADR-0006); the JVM-footprint concern applies equally to small e2 VMs.
The project started in C++20 (milestones M0–M2: build setup, configuration, logging, and an epoll networking layer). The developer is much more fluent in Java than in C++. The hard parts of this project are distributed-systems correctness: Raft safety, durable state, lease and fencing semantics, and failure testing. Language friction takes time and attention away from those.
AGENTS.md permits a different stack when "a documented architectural decision justifies an alternative". This is that record.
Which implementation language lets the developer build, test and reason about a correct, low-latency coordination system most effectively, without giving up the project's goals of implementing the core mechanisms from first principles?
- Stay with C++20. Best control over memory layout, allocation and system calls, plus sanitizers. But every milestone costs more for a developer less fluent in it, and memory-safety bugs compete with distributed-systems bugs for attention.
- Go. Simple concurrency and a fast runtime, but the goroutine scheduler hides the event-loop and threading model the project wants to build explicitly. The developer is not more fluent in it either.
- Rust. Memory and data-race safety with C++-level control, but a steep learning curve for the same developer.
- Java (25 LTS). The developer's strongest language. It is memory-safe and has a mature standard library for nonblocking I/O (NIO, epoll-backed on Linux), concurrency and file durability. Tooling is strong: JUnit, JMH, JDK Flight Recorder, async-profiler.
- Kotlin. Similar runtime trade-offs to Java, with a less familiar language.
Implement the system in Java 25 (LTS).
| Concern | Choice |
|---|---|
| Language level | Java 25 via Gradle toolchains |
| Build | Gradle 9 (Kotlin DSL), multi-module, wrapper committed; shared conventions in buildSrc |
| Compiler checks | -Xlint:all -Werror |
| Networking | java.nio channels + a single-threaded Selector event loop (epoll on Linux). No Netty, gRPC or similar. |
| Tests | JUnit Jupiter; integration tests as a separate Gradle test suite; shared test fixtures |
| Benchmarks (M11) | JMH; JDK Flight Recorder and async-profiler for profiling |
| Serialization | protobuf-java when message schemas arrive (M3), per ADR-0002 |
| Logging | The project's own small logger, passed explicitly (no static loggers, no logging framework) |
| Durability (M5) | FileChannel.force(true) for data and metadata; directory force after renames |
The architecture, safety requirements, milestones, wire format (ADR-0002) and Raft structure (ADR-0003) are unchanged. All M0–M2 functionality was ported one-to-one, with equivalent tests.
- Garbage-collection pauses. A stop-the-world pause is a process pause: it delays heartbeats, can trigger elections, and stretches a lease holder's view of time. AGENTS.md already requires safety under process pauses (fencing tokens, leases that do not rely on local clocks alone), so pauses must not break safety. They do affect availability and tail latency. Mitigations: keep allocation low on hot paths, run a low-pause collector (ZGC), log GC pauses, set election and lease timeouts with measured pause times in mind, and include pause injection in failure tests (M6, M8).
- No ThreadSanitizer equivalent. Java removes whole classes of memory bugs, so ASan and UBSan are not needed, but data races are not detected automatically. Mitigations: strict thread confinement with runtime checks (every loop-owned object rejects calls from other threads), deterministic simulation for Raft (ADR-0003), jcstress for any lock-free code, and static analysis to be added later.
- Less control over memory layout and system calls. Objects carry headers, NIO adds a layer over epoll (and allocates its selected-key set and per-call temporary direct buffers for heap
ByteBuffers), and false sharing is harder to control. These costs are measurable and will be measured in M11 before any optimization (direct buffers, buffer pooling,@Contended). - JIT warm-up. Startup latency is higher and early requests are slower. Benchmarks must use JMH or explicit warm-up and report steady-state and startup behaviour separately.
- Larger runtime footprint. The JVM needs more memory than a native binary, which matters on small EC2 instances. Heap sizing (
-Xmx, container-aware defaults) becomes part of deployment (M12).
- Development platform (amends ADR-0001). Java builds and tests run natively on macOS and Linux, so
./gradlewon the host is the primary workflow. The Docker image (deployment/docker/dev.Dockerfile, now based oneclipse-temurin:25-jdk) is kept for running the build on Linux and for failure injection withiptablesandtc(M6), which needs Linux. CI builds natively on an Ubuntu runner with JDK 25. - Sanitizer presets are gone. Their role is taken by
-Xlint:all -Werror,-eain tests, runtime thread-confinement checks, and the other measures above. - The C++ implementation is retired. The committed C++ code remains in git history (up to commit
31d2fc0). - Future milestones use Java facilities:
FileChannel.forcefor the WAL (M5), protobuf-java for messages (M3+), JMH and JFR for performance work (M11), and a JRE container image for deployment (M12).