By Bubi
This is the third article of the Java in Container series. You are welcome to follow the series. 😊
As more cloud-native micro-application are deployed on a large scale, the demand for microservice governance capabilities is getting bigger.
Java Agent technology enables businesses to focus on business logic. Middleware supports non-intrusive modification of program behavior through Java Agent, providing microservice governance capabilities.
In addition, Java Agent supports injection through environment variables. Middleware and cloud product teams can support this by setting environment variables.
Therefore, cloud-native observability and microservice governance capabilities based on Java Agent are increasingly used. For example, open-source Skywalking, OpenTelemetry, and commercialized Alibaba Cloud Microservice Engine (MSE) support Java Agent access.
Let’s use the MSE demo below as an example:
Install the ack-onepilot in a Kubernetes cluster and deploy the preceding demo.
First, you can access the gateway in the demo and verify that it can work normally.
You can seek the help of the MSE documentation to experience the microservice governance capabilities of end-to-end canary release.
We can see the injected agent when we log on to the container.
However, the result is that all JVMs in the container mount Agent.
For example, java –version
:
For example, jstack
:
Let's imagine this scenario: there is a problem with the online application. The O&M students want to jstack to pull the stacktrace information.
As a result, Java Agent must be loaded first, which wastes CPU and memory and makes it easier to miss the scene of troubleshooting.
However, Java Agent should be injected non-intrusively through environment variables while not injecting in some processes. Is there no way out?
First of all, JVM determines whether to inject Java Agent or not. We only need to modify the JVM.
The Dragonwell team has a lot of experience.
Second, let's look at the behavior of the JVM. The existing open-source behavior is listed below:
Originally, JDK_JAVA_OPTIONS was introduced to meet the demand very well, but stability comes first, so Java 8 must be supported.
After discussion with Dragonwell, the following amendments were determined.
Dragonwell_JAVA_OPTIONS
, similar to IBM_JAVA_OPTIONS
, sets certain Java parameters that are only used for Dragonwell.DRAGONWELL_JAVA_TOOL_OPTIONS_JDK_ONLY
is similar to JDK_JAVA_OPTIONS
.If DRAGONWELL_JAVA_TOOL_OPTIONS_JDK_ONLY=true
, the JAVA_TOOL_OPTIONS
will only be loaded by the Java command. jps/jstack
does not load environment variables and Java Agents.
After the preceding transformation, you can only load Java Agent to the business Java process. It does not affect the O&M commands provided by JDK (such as jps and jstack).
As an open-source project, the overall discussion of Dragonwell is completed on GitHub Issue. You are welcome to participate.
https://github.com/alibaba/dragonwell8/issues/330#issuecomment-1138083844
Let's use the latest Dragonwell version to run a business application and simulate the operation and maintenance scenario.
As you can see, the JDK O&M tool does not load the Java Agent.
The business process is loaded with the Java Agent (you can also see the application in the MSE governance console). This prevents Java Agent from affecting O&M scripts (such as java –version
).
Alibaba Cloud Microservice Engine (MSE) provides zero-cost, non-intrusive, and full-lifecycle microservice governance capabilities using Java Agent, SDK, and Service Mesh.
List of Capabilities Related to Cloud-Native Scenarios From JDK 9 to 19 (Part 1)
Why Can't Arthas Be Mounted in the Init Process in Container?
506 posts | 48 followers
FollowAlibaba Cloud Native Community - May 22, 2023
Alibaba Cloud Native Community - February 24, 2023
OpenAnolis - April 22, 2022
Aliware - April 10, 2020
Alibaba Cloud Native Community - April 29, 2024
Alibaba Cloud Native Community - May 22, 2023
506 posts | 48 followers
FollowMSE provides a fully managed registration and configuration center, and gateway and microservices governance capabilities.
Learn MoreAccelerate and secure the development, deployment, and management of containerized applications cost-effectively.
Learn MoreAlibaba Cloud Function Compute is a fully-managed event-driven compute service. It allows you to focus on writing and uploading code without the need to manage infrastructure such as servers.
Learn MoreLindorm is an elastic cloud-native database service that supports multiple data models. It is capable of processing various types of data and is compatible with multiple database engine, such as Apache HBase®, Apache Cassandra®, and OpenTSDB.
Learn MoreMore Posts by Alibaba Cloud Native Community