Code Monkey home page Code Monkey logo

spring-native-lab's Introduction

Getting Started

Motivation

Stack

  • Gradle 7.0.2
  • jdk 21.1.0.r11-grl (OpenJDK Runtime Environment GraalVM CE 21.1.0 (build 11.0.11+8-jvmci-21.1-b05))
  • spring-boot-starter-webflux
  • spring-native

Project organization

Two sub-projects were created to separate the logic:

  1. spring-native-microservice sub-project:
    Microservice project contains the Spring-Native setup to run this application on a GraalVM Native Image through Docker container
  2. standard-microservice sub-project:
    Simple microservice project using spring-boot-starter-webflux

Both projects contain only one controller class with the same content just to test purpose:

@RestController
@RequestMapping("/user")
public class UserController {

    @GetMapping("/getName")
    public Mono<String> getName() {
        return Mono.just("Ragnar Lothbrok (Vikings)");
    }
}

How-to Run

There is a README.md file inside each sub-projects describing how to run them.

Test

It was pretty straightforward. To perform the startup time test, I ran both subprojects as described in the README.md file, and the results were amazing. Take a look below :)

Results

standard-microservice

  • Build time: ~7 seconds
  • Start time: ~3 seconds (too much time)

spring-native-microservice

  • The $ gradle bootBuildImage command takes ~10 minutes to build a new Docker image

  • And the startup time was unbelievable 0.171 seconds \o/

Final comment

  • The startup time of the microservice project using Spring Native running on Native Image was ~17x faster than a standard microservice project running on HotSpot JVM.

My thoughts

The Spring team is doing a great job related to Spring Native.

This plugin came to compete with Micronaut and Quarkus, but I believe that the Spring team has a lot of work to do to release a version more trustful. I say that because in this simple POC, I faced many warnings and errors during the docker image build (maybe I forgot to set up something).

Anyways, congratulations Spring team!!!!! I'm impressed with the results and looking forward to testing new releases. \o/

spring-native-lab's People

Contributors

tcavalc-bronga avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.