

{"id":2704,"date":"2022-12-18T14:50:30","date_gmt":"2022-12-18T12:50:30","guid":{"rendered":"https:\/\/fabsk.eu\/blog\/?p=2704"},"modified":"2022-12-19T20:00:07","modified_gmt":"2022-12-19T18:00:07","slug":"microbenchmark-java-sprint-boot-memory-hungry-compared-to-rust-actix-web","status":"publish","type":"post","link":"https:\/\/fabsk.eu\/blog\/2022\/12\/18\/microbenchmark-java-sprint-boot-memory-hungry-compared-to-rust-actix-web\/","title":{"rendered":"Microbenchmark: Java (Sprint Boot) memory hungry compared to Rust (Actix-web)"},"content":{"rendered":"\n<p>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&rsquo;t reflect more complex applications, the ease to face various specific cases, to find developers, to adapt the current infrastructure and dev ecosystem\u2026).<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Micro-benchmark 1: receive a JSON and return a subset<\/h2>\n\n\n\n<p>An overly simplistic benchmark: it does almost no computation excepted deserializing and serializing a JSON.  <\/p>\n\n\n\n<p>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!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Micro-benchmark 2:&nbsp;query a Postgres DB to return the reading of a kanji<\/h2>\n\n\n\n<p>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.<\/p>\n\n\n\n<p>Both Java and Rust version had the same performance, the Rust one being less stable according to Apache Bench. But in term of memory\u2026 10Mo for Rust vs 160-190 (Spark) and 258-370Mo (Spring) for Java. <\/p>\n\n\n\n<p>If you are running an infrastructure based on Java \u00ab\u00a0micro\u00a0\u00bb-services, that will make quite an overhead on your hosting bill.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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&rsquo;t reflect more complex applications, the ease to face various specific cases, to find developers, to adapt the current [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[24,6,28,54],"tags":[],"class_list":["post-2704","post","type-post","status-publish","format-standard","hentry","category-dev","category-informatique","category-java","category-rust","\"lang=\"en"],"_links":{"self":[{"href":"https:\/\/fabsk.eu\/blog\/wp-json\/wp\/v2\/posts\/2704","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fabsk.eu\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fabsk.eu\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fabsk.eu\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fabsk.eu\/blog\/wp-json\/wp\/v2\/comments?post=2704"}],"version-history":[{"count":4,"href":"https:\/\/fabsk.eu\/blog\/wp-json\/wp\/v2\/posts\/2704\/revisions"}],"predecessor-version":[{"id":2709,"href":"https:\/\/fabsk.eu\/blog\/wp-json\/wp\/v2\/posts\/2704\/revisions\/2709"}],"wp:attachment":[{"href":"https:\/\/fabsk.eu\/blog\/wp-json\/wp\/v2\/media?parent=2704"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fabsk.eu\/blog\/wp-json\/wp\/v2\/categories?post=2704"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fabsk.eu\/blog\/wp-json\/wp\/v2\/tags?post=2704"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}