I tried the Java framework "Quarkus"

Introduction

There are more opportunities to run applications on Docker containers. Startup time is important when operating in a container. When running Java, it runs on the JVM, but it takes some time to start this JVM.

Quarkus introduced this time is a framework that realizes fast startup by creating a binary for native using GraalVM.

Execution environment

Prerequisites

--Java 8 and above --Maven 3.5.3 and above

GraalVM setup

From here graalvm-ce-1.0.0-rc13-macos-amd64.tar.gz Please download (as of March 12, 2019).

Unzip it and put the whole folder in / Library / Java / JavaVirtualMachines.

Set the GraalVM environment variable (GRAALVM_HOME).

.bash_profile


GRAALVM_HOME=/Library/Java/JavaVirtualMachines/graalvm-ce-1.0.0-rc13-macos-amd64/Contents/Home

Create a project

$ mvn io.quarkus:quarkus-maven-plugin:0.11.0:create \
    -DprojectGroupId=jp.acme \
    -DprojectArtifactId=getting-started \
    -DclassName="org.acme.quickstart.GreetingResource" \
    -Dpath="/hello"

Executing the above command will create a Maven project as shown below.

quarkus.png

Application launch

#Start in development mode
$ mvn compile quarkus:dev

Hot reload can be achieved by booting in development mode. Check the operation with the following command.

$ curl http://localhost:8080/hello

Build (native binary generation)

$ mvn package -Pnative -Dnative-image.docker-build=true
option Contents
-Pnative Specify when generating a natively executable binary
-Dnative-image.docker-build=true Specify when generating a native binary that matches the OS on Docker

Since we want to start it on Docker this time, also specify `` -Dnative-image.docker-build = true```.

It will take some time to build, probably because it generates native binaries.

Docker build

$ docker build -f src/main/docker/Dockerfile -t <Image name> .

Start Docker container

$ docker run -i --rm -p 8080:8080 <Image name>
2019-03-12 01:29:01,328 INFO  [io.quarkus](main) Quarkus 0.11.0 started in 0.004s. Listening on: http://0.0.0.0:8080
2019-03-12 01:29:01,328 INFO  [io.quarkus](main) Installed features: [cdi, resteasy]

What you should pay attention to here is the startup time. If you check the log after startup, it says `Quarkus 0.11.0 started in 0.004s`. In other words, you can see that it started in 0.004 seconds. It is early.

in conclusion

By using Quarkus, the application on the container starts up overwhelmingly faster. Quarkus itself has just come out, so I think it will be difficult to put it to practical use in production, but as development progresses and more information is available, I think there will be more opportunities for it to become practical. I'm looking forward to it in the future.

You can also add extensions to Quarkus. For example, the default is JavaEE standard CDI, but Spring-based CDI can be used. We will share information while investigating this area as well.

reference

-QUARKUS (head family site) -Quarkus: Introducing a new method to launch Java apps at high speed on a container

Recommended Posts

I tried the Java framework "Quarkus"
I tried the new era in Java
I tried QUARKUS immediately
I summarized the collection framework.
I tried Drools (Java, InputStream)
I tried the Docker tutorial!
I tried the VueJS tutorial!
I tried using Java REPL
I tried the FizzBuzz problem
[Java] I implemented the combination.
I studied the constructor (java)
I tried metaprogramming in Java
I tried to implement the Euclidean algorithm in Java
A survey of the Kubernetes native Java framework Quarkus
[JDBC] I tried to access the SQLite3 database from Java.
I tried to summarize the basics of kotlin and java
java framework
I tried to interact with Java
I tried UDP communication with Java
I tried to explain the method
Consideration on the 2017 Java Persistence Framework (1)
[Rails] I tried deleting the application
I tried using Java8 Stream API
I tried using JWT in Java
I tried to summarize Java learning (1)
I tried to summarize Java 8 now
I tried using the CameraX library with Android Java Fragment
I tried using Java memo LocalDate
I tried using GoogleHttpClient of Java
Java14 came out, so I tried record for the time being
I tried the input / output type of Java Lambda ~ Map edition ~
I tried to translate the error message when executing Eclipse (Java)
I tried to summarize the methods of Java String and StringBuilder
[Java] I tried to make a maze by the digging method ♪
I tried to move the Java compatible FaaS form "Fn Project"
I tried to display the calendar on the Eclipse console using Java.
I tried using Elasticsearch API in Java
I tried to summarize the methods used
Guess about the 2017 Java Persistence Framework (3) Reladomo
I tried Cassandra's Object Mapper for Java
I tried to summarize Java lambda expressions
[day: 5] I summarized the basics of Java
I tried to implement the Iterator pattern
I tried using OpenCV with Java + Tomcat
[Java] I personally summarized the basic grammar.
I tried to summarize the Stream API
I tried the AutoValue library in Intellij
I went to the Java Women's Club # 1
I tried Google's entrance exam (unofficial) [java]
[Introduction to Java] I tried to summarize the knowledge that I think is essential
I tried Spring.
I tried tomcat
Java framework comparison
I tried youtubeDataApi.
I tried refactoring ①
I tried FizzBuzz.
I tried JHipster 5.1
[Java] Collection framework
I tried using Docker for the first time
I tried putting Java on my Mac easily
[Rails] I tried to raise the Rails version from 5.0 to 5.2