DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Enterprise AI Trend Report: Gain insights on ethical AI, MLOps, generative AI, large language models, and much more.

2024 Cloud survey: Share your insights on microservices, containers, K8s, CI/CD, and DevOps (+ enter a $750 raffle!) for our Trend Reports.

PostgreSQL: Learn about the open-source RDBMS' advanced capabilities, core components, common commands and functions, and general DBA tasks.

AI Automation Essentials. Check out the latest Refcard on all things AI automation, including model training, data security, and more.

Related

  • Five Java Developer Must-Haves for Ultra-Fast Startup Solutions
  • Ways To Reduce JVM Docker Image Size
  • Shift-Left Monitoring Approach for Cloud Apps in Containers
  • Easily Update and Reload SSL for a Server and an HTTP Client

Trending

  • DSL Validations: Properties
  • Build Your Own Programming Language
  • Elevate Your Terminal Game: Hacks for a Productive Workspace
  • Understanding Kernel Monitoring in Windows and Linux
  1. DZone
  2. Coding
  3. Java
  4. Comparing the Efficiency of a Spring Boot Project to a Go Project

Comparing the Efficiency of a Spring Boot Project to a Go Project

In this article, compare the efficiency of a Spring Boot project as a GraalVM-native image and on the JDK to a Go project.

By 
Sven Loesekann user avatar
Sven Loesekann
·
Jan. 19, 24 · Analysis
Like (3)
Save
Tweet
Share
5.2K Views

Join the DZone community and get the full member experience.

Join For Free

AngularAndSpringWithMaps is a Sprint Boot project that shows company properties on a Bing map and can be run on the JDK or as a GraalVM native image. ReactAndGo is a Golang project that shows the cheapest gas stations in your post code area and is compiled in a binary. Both languages are garbage collected, and the AngularAndSpringWithMaps project uses the G1 collector. The complexity of both projects can be compared. Both serve as a frontend, provide rest data endpoints for the frontend, and implement services for the logic with repositories for the database access. How to build the GraalVM native image for the AngularAndSpringWithMaps project is explained in this article.

What To Compare

On the performance side, Golang and Java on the JVM or as a native image are fast and efficient enough for the vast majority of use cases. Further performance fine-tuning needs good profiling and specific improvements, and often, the improvements are related to the database. 

The two interesting aspects are:

  • Memory requirements
  • Startup time(can include warmup)

The memory requirements are important because the available memory limit on the Kubernetes node or deployment server is mostly reached earlier than the CPU limit. If you use less memory, you can deploy more Docker images or Spring Boot applications on the resource. 

The startup time is important if you have periods with little load and periods with high load for your application. The shorter the startup time is the more aggressive you can scale the amount of deployed applications/images up or down.

Memory Requirements

  • 420 MB AngularAndSpringWithMaps JVM 21
  • 280 MB AngularAndSpringWithMaps GraalVM native image
  • 128-260 MB ReactAndGo binary

The GraalVM native image uses significantly less memory than the JVM jar. That makes the native image more resource-efficient. The native image binary is 240 MB in size, which means 40 MB of working memory. 

The ReactAndGo binary is 29 MB in size and uses 128-260 MB of memory depending on the size of the updates it has to process. That means if the use case would need only 40 MB of working memory like the GraalVM native image, 70 MB would be enough to run it. That makes the Go binary much more resource-efficient. 

Startup Time

  • 4300ms AngularAndSpringWithMaps JVM 21
  • 220ms AngularAndSpringWithMaps GraalVM native image
  • 100ms ReactAndGo binary

The GraalVM native image startup time is impressive and enables the scale-to-zero configurations that start the application on demand and scale down to zero without load. The JVM start time requires one running instance as a minimum.

The ReactAndGo binary startup time is the fastest and enables scale to zero. 

Conclusion

The GraalVM native image and the Go binary are the most efficient in this comparison. Due to their lower memory requirements can, the CPU resources be used more efficiently. The fast startup times enable scale to zero configurations that can save money in on-demand environments. The winner is the Go project. 

The result is that if efficient use of hardware resources is the most important to you, Go is the best. If your developers are most familiar with Java then the use of GraalVM native image can improve the efficient use of hardware resources. Creating GraalVM native images needs more effort and developer time. Some of the effort can be automated, and with some of the effort, that would be hard. Then the question becomes: Is the extra developer time worth the saved hardware resources?

GraalVM Java Development Kit Java virtual machine Go (programming language) Spring Boot

Opinions expressed by DZone contributors are their own.

Related

  • Five Java Developer Must-Haves for Ultra-Fast Startup Solutions
  • Ways To Reduce JVM Docker Image Size
  • Shift-Left Monitoring Approach for Cloud Apps in Containers
  • Easily Update and Reload SSL for a Server and an HTTP Client

Partner Resources


Comments

ABOUT US

  • About DZone
  • Send feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: