Rate This Document
Findability
Accuracy
Completeness
Readability

Enabling the JBooster Feature

Introduction

  • A single cloud application instance is often allocated with few resources, and elastic scaling is frequently performed. The startup speed of a typical JVM application is especially slow in such scenarios.
  • CPU resources required by a cloud application are determined by the load at application startup and the load when the application is running stably (or the load during peak hours).
  • Through data sharing and remote compilation, JBooster can accelerate application startup, reduce CPU usage, speed up elastic scaling, and cuts cloud application deployment costs.

Application Scenario

Application startup takes a long time due to limited CPU resources, long class loading time, or long compile time.

Restrictions

  • The JBooster feature is available in BiSheng JDK 17 (since 17.0.12).
  • The client and server are deployed in the same trusted zone. Users need to ensure communication security.
  • Ahead of Time (AOT) compilation on the server requires the ld instruction.
    • For RPM-based OSs (such as CentOS, Fedora, and openEuler), use yum to install ld.
      1
      yum install binutils
      
    • For Debian-based OSs (such as Ubuntu and Debian), use apt to install ld.
      1
      apt install binutils
      

How to Use

  1. Start the JBooster server.

    After the server is started, the message "The JBooster server is ready!" is displayed. When using the JBooster server, ensure that the server is started and cannot be stopped manually. If you need to run other commands, start another window.

    1
    $JAVA_HOME/bin/jbooster --server-port=<port>
    

    In the preceding command, <port> can be customized within the range of 1024 to 65535.

    Run the jbooster --help command to view available parameters.

    1
    $JAVA_HOME/bin/jbooster --help
    
  2. Build an application package.

    This section uses spring-petclinic-*.*.*-SNAPSHOT.jar as an example. The build process depends on the Maven tool. Ensure that Maven has been installed in the build environment.

    Build the application package spring-petclinic-*.*.*-SNAPSHOT.jar by referring to the sample application on GitHub.
    1
    2
    3
    4
    5
    6
    7
    git clone https://github.com/spring-projects/spring-petclinic.git
    wget https://dlcdn.apache.org/maven/maven-3/3.9.6/binaries/apache-maven-3.9.6-bin.tar.gz
    tar -xf apache-maven-3.9.6-bin.tar.gz
    export PATH=$PWD/apache-maven-3.9.6/bin:$PATH
    cd spring-petclinic
    git reset --hard 2daa3993ee8dce8ec72cf96bc5ef7aee6e36f8fb
    mvn package -DskipTests=true
    

    To use the mvn command, you may need to configure a proxy based on your environment requirements.

    After the build is successful, a JAR package named spring-petclinic-*.*.*-SNAPSHOT.jar is generated in the ./target folder. The version number of the JAR package varies with the code repository.

  3. Start the client.

    If the client is started for the first time, generate an acceleration package. Specify the server address in JBoosterAddress and the port number in JBoosterPort. Ensure that the port number is the same as that specified in --server-port. After spring-petclinic-3.2.0.jar is started, the "(process running for X.XXX)" log is printed, where X.XXX indicates the startup time. You can press Ctrl+C to stop the client.

    1
    $JAVA_HOME/bin/java -XX:+UnlockExperimentalVMOptions -XX:+UseJBooster -XX:JBoosterAddress=127.0.0.1 -XX:JBoosterPort=<port> -jar ./target/spring-petclinic-*.*.*-SNAPSHOT.jar
    

    If you start this client again using the same startup commands, the log output shows that the startup time is reduced. In the preceding command, <port> can be customized. Ensure the value is the same as that configured in 1.