Scala Without the JVM: Close to Rust's Speed, With 25x Less Memory Than the JVM | Uni

wvlet.org10 min read

Compiled with Scala Native, Uni's HTTP server approaches Rust's throughput while using approximately 25 times less memory than the JVM, allowing developers to write ordinary garbage-collected Scala without managing memory ownership by hand. A CPU profile revealed that the initial performance gap was caused by serialization locks in the Boehm garbage collector. After implementing targeted optimizations—including reduced request handling overhead, streaming JSON encoders, pooled send buffers, and a default single Boehm marker thread—the native server achieved significant performance gains. Open article →

More on this topic