Coder Social home page Coder Social logo

jcudos's Introduction

An AppCDS automation toolchain for Spring Boot

jCuDoS is a set of CLI tools for simplifying the use of Application Class Data Sharing to multiple Spring Boot applications of the same project. Usually such applications have quite large common subset of the same classes (from JDK to Spring to application libraries) what makes the leveraging of AppCDS beneficial from both startup time and (especially) memory footprint point of view.

Project status

⚠️ The project is not completed and discontinued. It implements the very basic algorithm (see below) and needs some additional work to become production-ready. Please feel free to support its further development by forking, making an issue/PR, documenting or just giving the feedback.

Description

jCuDoS consists of several useful commands which can be called either separately or together (by means of the root jcudos command). In the last case, they will perform the following algorithm.

The algorithm of AppCDS preparation for a set of Spring Boot microservices of the same project

Preconditions

  • There is a set of Spring Boot “fat” JARs from all the applications (microservices);
  • All the JARs reside on the same filesystem (not necessary in the same directory);
  • All the microservices were at least once launched with the -XX:DumpLoadedClassList JVM option.

Input Data

  1. A Glob to the lists of classes gathered with -XX:DumpLoadedClassList;
  2. A Glob to “fat” JARs;
  3. Desired path to a common output directory (the following steps assume _appcds).

The algorithm steps

A. Processing class lists

  1. Find out the common part of the lists;
  2. Save it into _appcds/_shared/list/classes.list 0️⃣.

B. Processing of each “fat” JAR

  1. Detect the name of the start class. If no name is detected (i.e. the JAR is not a Spring Boot one), skip the archive. Remember the name of the application as “raw” class name in lower case (referring later as <appname>, for example class named com.example.MyCoolApp yields mycoolapp application name).
  2. Store the start class name into _appcds/<appName>/start-class.txt 1️⃣.
  3. Extract the libraries of the current “fat” JAR into _appcds/<appName>/lib/.
  4. Convert current “fat” JAR into _appcds/<appName>/lib/<appName>.slim.jar 2️⃣.

C. Creation of the common archive

  1. Find out the common libraries names from listings of each _appcds/<appName>/lib/ directory.

  2. Copy all the found libraries into _appcds/_shared/lib/.

  3. Compose the _appcds/_shared/list/classpath.arg 5️⃣ file from absolute paths of the copied​ libraries.

  4. Remember the list of absolute paths of// the common libraries 3️⃣.

  5. Navigate to _appcds directory and execute there:

    java -Xshare:dump \
         -XX:SharedClassListFile=_shared/list/classes.list \
         -XX:SharedArchiveFile=_shared/jsa/classes.jsa \
         @_shared/list/classpath.arg &> log/dump.log

    Here were used: _appcds/_shared/list/classes.list 0️⃣ and _appcds/_shared/list/classpath.arg 5️⃣.

D. Preparation of microservices for launching

  1. Remove all the common libraries 3️⃣ from the each _appcds/<appName>/lib/ directory.
  2. Compose _appcds/<appName>/appcds.arg 4️⃣ file from:
    1. -XX:SharedArchiveFile=_appcds/_shared/jsa/classes.jsa option;
    2. -classpath option which in turn consists of:
      1. common libraries list 3️⃣;
      2. own libraries list taken as _appcds/<appName>/lib/ directory listing. The slim JAR _appcds/<appName>/lib/<appName>.slim.jar 2️⃣ should be included there as well;
      3. the name of the start class 1️⃣.

Launching a microservice with AppCDS (out of the algorithm’s scope)

  • In the launch script, just replace the -jar <appName>.jar with @appcds.arg 4️⃣.

Want to know more?

➕ There is much more information about the project like examples, statistics, observations, comparison tables, etc. Please contact me if it interests you.

jcudos's People

Contributors

toparvion avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.