Connecting a JVM to a Cloud Native Compiler
You connect an Azul Zulu Prime Build of OpenJDK (Azul Zulu Prime JVM) to a Cloud Native Compiler service by specifying the IP address of the service along with other command-line options. If the Cloud Native Compiler cannot respond to the compilation requests in time, the Azul Zulu Prime JVM switches to local JIT compilation until the service recovers.
Determining the Cloud Native Compiler Endpoint
Use the IP address of the Cloud Native Compiler gateway
service as the connection endpoint for your JVMs.
If the containers running your JVMs are deployed to the same Kubernetes cluster as the Cloud Native Compiler service, the service endpoint is gateway.compiler.svc.cluster.local:50051
.
If the containers are deployed outside the Cloud Native Compiler cluster, find the endpoint using the following steps:
-
Run the following command:
$ kubectl -n compiler get services -
Look for the
gateway
service and note the port corresponding to port 50051 inside the container. This is the port to use for connecting VMs to this Cloud Native Compiler cluster.$ service/gateway NodePort 10.233.15.55 <none> 8080:31951/TCP,50051:30926/TCP 52dIn this example the port is 30926.
-
Run the
kubectl get nodes
command and note the IP address or name of any node. -
Concatenate node IP with service port to get something like
10.22.20.131:30926
. Do not prefix it withhttp://
.
Connecting the JVM
You can only connect to Cloud Native Compiler from any Azul Zulu Prime JDK versions 21.09.1.0 and later. Run java -jar
with the -XX:CNCHost
flag as described below.
$ java -jar my-app.jar -XX:CNCHost:10.22.20.131:30926
To view compiler info and ensure that the JVM is correctly connecting to the CNC service, use the -Xlog:concomp
flag.
By default the Azul Zulu Prime JDK connects to the CNC service using SSL. If you installed the base
configuration of CNC service which does not use SSL, you must use the -XX:+CNCInsecure
flag to instruct the Azul Zulu Prime JDK to connect without SSL.
If you attempt to connect to a CNC service that is running without SSL and do not specify the -XX:+CNCInsecure
flag, you get the following error (visible with the -Xlog:concomp
flag):
$ E1011 13:16:23.198074100 29 ssl_transport_security.cc:1446] Handshake failed with fatal error SSL_ERROR_SSL: error:1408F10B:SSL routines:ssl3_get_record:wrong version number.
Cloud Native Compiler JVM Options
Flag | Description |
---|---|
-XX:CNCHost=host:port |
Address where CNC service is listening. The default is localhost:50051. |
-XX:CNCMaxConcurrentCompiles=M |
Maximum number of compilation requests a JVM sends to remote compiler before blocking and waiting for results. Default value is -1, which defers to the settings in the |
-XX:+CNCAbortOnBadChannel |
With this flag VM will crash if it loses connection to remote compiler. |
-XX:+CNCInsecure |
Instructs the Azul Zulu Prime JVM to communicate directly with the CNC service without using SSL. Use this option if you installed the CNC service without SSL using the |
-XX:CNCSSLRootsPath=<path to cert.pem> |
Instructs the Azul Zulu Prime JVM to use and trust a specified SSL certificate on the filesystem |
-Xlog:concomp |
Display compiler output when running a program. |
Fallback to Local JIT Compilation
When you connect an Azul Zulu Prime JVM to a Cloud Native Compiler (CNC), the JVM attempts to fetch all JIT compilations from the service. If the Cloud Native Compiler cannot meet the JVM’s requests in time, the JVM automatically falls back to performing optimizations on the client. Factors that can cause a Cloud Native Compiler service to not meet optimization demand include:
-
The service does not have the corresponding Compiler Engine installed. To force an Azul Zulu Prime JVM to fail when requesting optimizations from a Cloud Native Compiler that doesn’t have the corresponding Compiler Engine installed, use the
-XX:+CNCAbortOnBadChannel
flag. -
The service is down or cannot be reached.
-
The service does not have enough capacity to meet the optimization requests. If you have autoscaling enabled, this is often a temporary problem as new resources come online.
When an Azul Zulu Prime JVM switches to local JIT compilation, it keeps checking whether the Cloud Native Compiler service is ready to perform optimizations. Once the Cloud Native Compilation service is back online and healthy, the Azul Platform Prime JVM switches back to requesting optimizations from the service.
The following output in the JVM concomp log show when fallback to local JIT compilation is enabled and disabled:
$ [110,991s][info ][concomp] [LocalFallback] local compilation queue disabled
$ [111,018s][info ][concomp] [LocalFallback] local compilation queue enabled
Using Cloud Native Compiler with ReadyNow
You can use Cloud Native Compiler with ReadyNow to shorten the pre-main JIT compilation time of ReadyNow. You pass a ReadyNow profile into a JVM that is configured to use Cloud Native Compiler as normally using the -XX:ProfileLogIn=<file>
flag.
Note
|
Using -XX:ProfileLogOut=<file> to generate a profile from a JVM that is using Cloud Native Compiler is not fully supported at this time. Using this profile could have unexpected results. You should generate your profile with an Azul Zulu Prime JVM that is doing local JIT compilation.
|