Comparing Native Image Size of Java ,Spring Boot, Quarkus and Micronaut

In this blog post we will look at the native image size of Java, Java based frameworks Spring Boot, Quarkus and Micronaut.

Based on the below tweet, I became curious to know the bare minimum size of a native application for Java and Java based frameworks.

Code Used in Native Images

I am trying to use simple class or Rest API to compare image sizes.

Java – A class which prints “Hello World”

Spring Boot, Quarkus, Microanut – Rest API which responds with “Hello World”

Hardware

I am using GitHub Action to build the native images. For x86 architecture, I have used the hardware hosted by GitHub and for ARM64 architecture I have used self hosted runners.

X86

Hardware specification for Windows and Linux virtual machines:

  • 2-core CPU (x86_64)
  • 7 GB of RAM
  • 14 GB of SSD space

Hardware specification for macOS virtual machines:

  • 3-core CPU (x86_64)
  • 14 GB of RAM
  • 14 GB of SSD space

ARM64

Hardware specification for Linux virtual machines:

  • 1-core CPU ( ARM64 )
  • 4 GB of RAM
  • 40 GB of Hard disk Space

Note : I am using Oracle Cloud ampere (Arm64) processor

Hardware specification for Mac OS :

  • 8-core CPU (ARM64)
  • 16 GB of RAM
  • 500 GB of SSD space

Java

OSSize (MB)Build Time
Windows (x86)11.22m 38s
Linux (x86)11.41m 39s
Mac (x86)11.13m 10s
Linux (ARM64)11.52m 41s
Mac (ARM64)11.338s

Repo : https://github.com/sureshgadupu/java-native-image

Native Images : https://github.com/sureshgadupu/java-native-image/releases/tag/0.0.1

Spring Boot

OSSize (MB)Build Time
Windows (x86)67.87m 8s
Linux (x86)70.55m 15s
Mac (x86)67.26m 1s
Linux (ARM64)70.88m 54s
Mac (ARM64)681m 44s

Repo : https://github.com/sureshgadupu/sb3-native-image

Native Images : https://github.com/sureshgadupu/sb3-native-image/releases/tag/0.1.5

Quarkus

OSSize (MB)Build Time
Windows (x86)417m 31s
Linux (x86)41.43m 43s
Mac (x86)40.56m 52s
Linux (ARM64)41.57m 40s
Mac (ARM64)411m 21s

Repo : https://github.com/sureshgadupu/quarkus-native-image

Native Images: https://github.com/sureshgadupu/quarkus-native-image/releases/tag/0.0.9

Micronaut

OSSize (MB)Build Time
Windows (x86)55.86m 32s
Linux (x86)60.13m 52s
Mac (x86)55.27m 41s
Linux (ARM64)60.48m 14s
Mac (ARM64)562m 2s

Repo : https://github.com/sureshgadupu/micronaut-native-image

Native Images : https://github.com/sureshgadupu/micronaut-native-image/releases/tag/0.0.5

Size

  • Java native image size is only around 12MB
  • Quarkus has the lowest size (Around 42 MB) while Spring Boot has the largest size (around 71 MB) , Micronaut sitting in the middle.
  • Micronaut has highest image size difference ( around 5 MB) among different architectures.

Build Time

While we can not compare build times for across different architectures of single framework as we are using different hardware specification we could compare across different frameworks as they were built using same spec’d hardware.

Spring BootQuarkusMicronaut
Windows (x86)7m 8s7m 31s6m 32s
Linux (x86)5m 15s3m 43s3m 52s
Mac (x86)6m 1s6m 52s7m 41s
Linux (ARM64)8m 54s7m 40s8m 14s
Mac (ARM64)1m 44s1m 21s2m 2s

Quarkus build time is lowest for Linux (x86), Linux (ARM64), Mac (ARM64) while Spring Boot claims for Mac (x86) and Micronaut for Windows (x86)

Similar Posts