What is quarkus
Quarkus is an open source cloud native framework integrating k8s, which is used to create k8s native references adapted to GraalVM and OPenJDK HotSpot. Here are two new nouns: GraalVM and Open JDK HotSpot. Let's take a look at these two things first:
One sentence summary: refers to HotSpot VM, which is a virtual machine built in Sun JDK and OpenJDK. It has this name because it uses hotspot code detection technology.
mention HotSpot VM，Believe all Java Programmers know that it is Sun JDK and OpenJDK The virtual machine in is also the most widely used one at present Java Virtual machine. But not everyone knows that this virtual machine, which looks "pure blood" at present, was not originally created by Sun Developed by a company called“ Longview Technologies"Even this virtual machine was not originally designed for Java Language, which comes from Strongtalk VM， A considerable number of technologies in this virtual machine come from a support Self Language implementation "achieve C Language 50%The virtual machine designed for the goal of "execution efficiency", Sun The company noticed that the virtual machine was JIT There are many excellent concepts and practical effects in compilation, which were acquired in 1997 Longview Technologies The company thus obtained HotSpot VM. HotSpot VM Both inherited Sun The advantages of the previous two commercial virtual machines (such as accurate memory management mentioned earlier) also have many new technical advantages, such as HotSpot It refers to its hot code detection technology (actually two) VM Basically independent products of the same period, HotSpot Earlier, HotSpot From the beginning, it was the exact formula GC， and Exact VM There are also and HotSpot Almost the same hot spot detection Exact VM and HotSpot VM Which becomes Sun Main supported VM Products, in Sun There have been debates within the company, HotSpot beat Exact It's not a technical victory, HotSpot VM The hot code detection capability of can find the code with the most compilation value through the execution counter, and then notify JIT The compiler compiles in method units. If a method is called frequently, or there are many valid cycles in the method, standard compilation and standard compilation will be triggered respectively OSR(Stack replacement) compilation action. Through the proper cooperation between the compiler and the interpreter, the balance can be achieved between the optimized program response time and the optimal execution performance, and the program can be executed without waiting for the output of local code. The time pressure of immediate compilation is also relatively reduced, which helps to introduce more code optimization technologies and output higher quality local code . In 2006 JavaOne At the conference, Sun The company announced that it would eventually Java Open source, and in the following year, will continue to JDK Various parts of (including, of course) HotSpot VM)stay GPL The source code is disclosed under the protocol, and on this basis, a OpenJDK. So, HotSpot VM It became Sun JDK and OpenJDK Two achieve extremely close JDK Common virtual machine for the project. In 2008 and 2009, Oracle The company acquired BEA Company and Sun Company, so Oracle It has two excellent models at the same time Java Virtual machine: JRockit VM and HotSpot VM. Oracle The company announced that it would release in the near future (about JDK 8 The integration of these two virtual machines will be completed to complement each other's advantages. The integration method is basically HotSpot Based on, transplantation JRockit Excellent features, such as using JRockit Garbage collector and MissionControl Services, using HotSpot of JIT Compiler and hybrid runtime system.
One sentence summary: a cross language full stack virtual machine enhanced on the basis of HotSpot virtual machine can be used as "any language" The principle of the running platform is to convert the source code of these languages or the compiled intermediate format of the source code into an intermediate representation that can be accepted by Graal VM through the interpreter, and then uniformly optimize. The optimized languages can run in this virtual machine at the same time, so as to reduce the communication overhead of different languages.
Quarkus runs on k8s. It can deploy an optimized k8s application and quickly start and run new k8s instances.
I use vscode. I can install the plug-in of Quarkus first, and then press F1 to find Quarkus: build a Quarkus project to complete the creation of scaffold.
There are four main core parts:
- src\main\java\org\acme JAX-RS(Java API for RESTful Web Services) resource
- src\test\java\org\acme test for JAX-RS
- src\main\resources static resources
The contents in docker folder generally do not need to be modified. The meaning of the file is as follows:
- Dockerfile.jvm builds containers that run Quarkus applications in JVM mode
- Dockerfile.legacy-jar builds a container for running Quarkus applications in JVM mode
- Dockerfile.multigrade one-stop construction of native application image
- Dockerfile.native builds a container that runs Quarkus applications in native (no JVM) mode
- Dockerfile.native-troubleshooting builds a troubleshooting container that runs Quarkus applications in native (no JVM) mode
Q: gradlew is used as the dependency management tool of the project, so the next command will use gradlew. For maven projects, you can use mvnw, but the command format will be different. You can refer to the help provided on the command line.
./gradlew quarkusDev // Turn on hot loading
The deployment port will be given in the deployment process. My port is 8080. Open localhost:8080 to see the following page, indicating that the deployment is successful
 GraalVM: Java in the era of microservices https://zhuanlan.zhihu.com/p/137836206