Microbenchmark: Java (Sprint Boot) memory hungry compared to Rust (Actix-web)

I ran two micro-benchmarks comparing web service endpoints implemented in Java (Sprint Boot and Spark) and Rust/Actix-web. In summary, performance were equal or not that different, but memory usage was extremely higher in Java. (disclaimer: micro-benchmarks don’t reflect more complex applications, the ease to face various specific cases, to find developers, to adapt the current infrastructure and dev ecosystem…).

Micro-benchmark 1: receive a JSON and return a subset

An overly simplistic benchmark: it does almost no computation excepted deserializing and serializing a JSON.

Java version performed between 0% and 25% slower (according to the number of concurrent calls, the more the better). But the memory consumption was 5Mo for Rust and larger than 300Mo for Java!

Micro-benchmark 2: query a Postgres DB to return the reading of a kanji

The service takes a kanji character (Japanese character of Chinese origin) as a query parameter, search in a Postgres DB all the readings associated to this kanji and return them as a JSON.

Both Java and Rust version had the same performance, the Rust one being less stable according to Apache Bench. But in term of memory… 10Mo for Rust vs 160-190 (Spark) and 258-370Mo (Spring) for Java.

If you are running an infrastructure based on Java « micro »-services, that will make quite an overhead on your hosting bill.

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *