Visit Azul.com Support

Connecting a JVM to a Cloud Native Compiler

When you connect an Azul Zulu Prime Build of OpenJDK (Azul Zulu Prime JVM) to a Cloud Native Compiler (CNC), the JVM will attempt to fetch all JIT compilations from the service. If the Cloud Native Compiler does not have the corresponding Compiler Engine installed, or if the service cannot be reached, the JVM will automatically switch to performing optimizations on the client VM using only the C1 compiler. Note that the code produced by the C1 compiler is significantly slower than the code produced by the Falcon compiler on either a regular Azul Zulu Prime JVM or on Cloud Native Compiler.

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.

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:

  1. Run the following command:

     
    kubectl -n compiler get services
  2. 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 52d

    In this example the port is 30926.

  3. Run the kubectl get nodes command and note the IP address or name of any node.

  4. Concatenate node IP with service port to get something like 10.22.20.131:30926. Do not prefix it with http://.

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:+UseCNC and -XX:CNCHost flags as described below.

 
java -jar my-app.jar -XX:+UseCNC -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:+UseCNC

Instructs the Azul Zulu Prime JVM to request compilations from a CNC service.

-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 service compile-broker config. Set to a positive number to override the service setting and use this number as the value.

-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 <cnc-install-dir>/deployment-k8s/base profile.

-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.