Skip to content

Commit 91d8de8

Browse files
committed
Run Java applications on the Microsoft Cobalt 100 processors
Signed-off-by: odidev <[email protected]>
1 parent 89b6c0c commit 91d8de8

File tree

7 files changed

+375
-0
lines changed

7 files changed

+375
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
title: Create an Arm based cloud VM using Microsoft Cobalt 100 CPU
3+
weight: 3
4+
5+
### FIXED, DO NOT MODIFY
6+
layout: learningpathall
7+
---
8+
9+
## Introduction
10+
11+
There are several ways to create an Arm-based Cobalt 100 VM : the Microsoft Azure console, the Azure CLI tool, or using your choice of IaC (Infrastructure as Code). This guide will use the Azure console to create a VM with Arm-based Cobalt 100 Processor.
12+
13+
This learning path focuses on the general-purpose VMs of the D series. Please read the guide on [Dpsv6 size series](https://learn.microsoft.com/en-us/azure/virtual-machines/sizes/general-purpose/dpsv6-series) offered by Microsoft Azure.
14+
15+
If you have never used the Microsoft Cloud Platform before, please review the microsoft [guide to Create a Linux virtual machine in the Azure portal](https://learn.microsoft.com/en-us/azure/virtual-machines/linux/quick-create-portal?tabs=ubuntu).
16+
17+
#### Create an Arm-based Azure Virtual Machine
18+
19+
Creating a virtual machine based on Azure Cobalt 100 is no different from creating any other VM in Azure. To create an Azure virtual machine, launch the Azure portal and navigate to Virtual Machines.
20+
21+
Select “Create”, and fill in the details such as Name, and Region. Choose the image for your VM (for example – Ubuntu 24.04) and select “Arm64” as the VM architecture.
22+
23+
In the “Size” field, click on “See all sizes” and select the D-Series v6 family of VMs. Select “D4ps_v6” from the list and create the VM.
24+
25+
![Instance Screenshot](./instance.png)
26+
27+
The VM should be ready and running; you can SSH into the VM using the PEM key, along with the Public IP details.
28+
29+
{{% notice Note %}}
30+
31+
To learn more about Arm-based VMs in Azure, refer to “Getting Started with Microsoft Azure” in [Get started with Arm-based cloud instances](https://learn.arm.com/learning-paths/servers-and-cloud-computing/csp/azure) .
32+
33+
{{% /notice %}}
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
---
2+
title: Install the JDK and build an application
3+
weight: 4
4+
5+
### FIXED, DO NOT MODIFY
6+
layout: learningpathall
7+
---
8+
9+
10+
### Platform Overview
11+
Whether you're using an Azure Linux 3.0 Docker container or a VM created from a custom Azure Linux 3.0 image, the deployment and benchmarking steps remain the same.
12+
13+
### Working inside Azure Linux 3.0 Docker container
14+
The Azure Linux Container Host is an operating system image that's optimized for running container workloads on Azure Kubernetes Service (AKS). Microsoft maintains the Azure Linux Container Host and based it on CBL-Mariner, an open-source Linux
15+
distribution created by Microsoft.
16+
To know more about Azure Linux 3.0, kindly refer [What is Azure Linux Container Host for AKS](https://learn.microsoft.com/en-us/azure/azure-linux/intro-azure-linux). Azure Linux 3.0 offers support for Aarch64. However, the standalone VM image for Azure Linux 3.0 or CBL Mariner 3.0 is not available for Arm.
17+
18+
Hence, to use the default software stack provided by the Microsoft team, this guide will focus on creating a docker container with Azure Linux 3.0 as a base image and will build
19+
and run the Java application inside the container, with the default JDK provided by the Microsoft team via Azure Linux 3.0 environment.
20+
21+
### Create Azure Linux 3.0 Docker Container
22+
The [Microsoft Artifact Registry](https://mcr.microsoft.com/en-us/artifact/mar/azurelinux/base/core/about) offers updated docker image for the Azure Linux 3.0.
23+
24+
To create a docker container, install docker, and then follow the below instructions:
25+
26+
```console
27+
$ sudo docker run -it --rm mcr.microsoft.com/azurelinux/base/core:3.0
28+
```
29+
30+
The default container startup command is bash. tdnf and dnf are the default package managers.
31+
32+
### Install Java
33+
34+
This Azure Linux 3.0 image does not include Java, so you need to install it.
35+
36+
First update tdnf:
37+
38+
```console
39+
$ tdnf update -y
40+
```
41+
Then install java-devel:
42+
43+
```console
44+
$ tdnf install -y java-devel
45+
```
46+
47+
Java-devel installs both the default JRE and JDK provided by Azure Linux 3.0.
48+
49+
Check to ensure that the JRE is properly installed:
50+
51+
```console
52+
$ java -version
53+
```
54+
55+
**Your output will look like this:**
56+
57+
```output
58+
openjdk version "11.0.27" 2025-04-15 LTS
59+
OpenJDK Runtime Environment Microsoft-11371464 (build 11.0.27+6-LTS)
60+
OpenJDK 64-Bit Server VM Microsoft-11371464 (build 11.0.27+6-LTS, mixed mode,
61+
sharing)
62+
```
63+
64+
**Check to ensure that the JDK is properly installed:**
65+
66+
```console
67+
$ javac -version
68+
```
69+
Your output will look like this:
70+
71+
```output
72+
javac 11.0.27
73+
```
74+
75+
Set Java Environment Variable for Arm:
76+
77+
```console
78+
$ export JAVA_HOME=/usr/lib/jvm/msopenjdk-11
79+
$ export PATH=$JAVA_HOME/bin:$PATH
80+
```
81+
82+
{{% notice Note %}}
83+
Azure Linux 3.0 offers the default JDK version 11.0.27. It’s important to ensure that your version of OpenJDK for Arm is at least 11.0.9, or above. There is a large performance gap between OpenJDK-11.0.8 and OpenJDK 11.0.9. A patch added in 11.0.9 reduces false-sharing cache contention.
84+
For more information, you can view this [Arm community blog](https://community.arm.com/arm-community-blogs/b/architectures-and-processors-blog/posts/java-performance-on-neoverse-n1).
85+
86+
The [Arm Ecosystem Dashboard](https://developer.arm.com/ecosystem-dashboard/) also recommends Java/OpenJDK version 11.0.9 as minimum recommended on the Arm platforms.
87+
{{% /notice %}}
88+
89+
### Deploy a Java application with Tomcat-like operation
90+
Apache Tomcat is a Java-based web application server (technically, a Servlet container) that executes Java web applications. It's widely used to host Java servlets, JSP (JavaServer Pages),
91+
and RESTful APIs written in Java.
92+
The below Java class simulates the generation of a basic HTTP response and measures the time taken to construct it, mimicking a lightweight Tomcat-like operation. It measures how long it
93+
takes to build the response string, helping evaluate raw Java execution efficiency before deploying heavier frameworks like Tomcat.
94+
Create a file named `HttpSingleRequestTest.java`, and add the below content to it:
95+
96+
```java
97+
public class HttpSingleRequestTest {
98+
public static void main(String[] args) {
99+
long startTime = System.nanoTime();
100+
String response = generateHttpResponse("Tomcat baseline test on Arm64");
101+
long endTime = System.nanoTime();
102+
double durationInMicros = (endTime - startTime) / 1_000.0;
103+
System.out.println("Response Generated:\n" + response);
104+
System.out.printf("Response generation took %.2f microseconds.%n", durationInMicros);
105+
}
106+
private static String generateHttpResponse(String body) {
107+
return "HTTP/1.1 200 OK\r\n" +
108+
"Content-Type: text/plain\r\n" +
109+
"Content-Length: " + body.length() + "\r\n\r\n" +
110+
body;
111+
}
112+
}
113+
```
114+
Compile and Run Java program :
115+
116+
```console
117+
$ javac HttpSingleRequestTest.java
118+
$ java -Xms128m -Xmx256m -XX:+UseG1GC HttpSingleRequestTest
119+
```
120+
121+
- -Xms128m sets the initial heap size for the Java Virtual Machine to 128 MB.
122+
- -Xmx256m sets the maximum heap size for the JVM to 256 MB.
123+
- -XX:+UseG1GC enables the G1 Garbage Collector (Garbage First GC), designed for low pause times and better performance in large heaps.
124+
125+
Output of java program on the Arm VM:
126+
```output
127+
128+
$ javac HttpSingleRequestTest.java
129+
$ java -Xms128m -Xmx256m -XX:+UseG1GC HttpSingleRequestTest
130+
Response Generated:
131+
HTTP/1.1 200 OK
132+
Content-Type: text/plain
133+
Content-Length: 29
134+
135+
Tomcat baseline test on Arm64
136+
Response generation took 22125.79 microseconds.
137+
```
138+
Output summary:
139+
140+
- The program generated a fake HTTP 200 OK response with a custom message.
141+
- It then measured and printed the time taken to generate that response (22125.79 microseconds).
142+
- This serves as a basic baseline performance test of string formatting and memory handling on the JVM running on an Azure Arm64 instance.
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
---
2+
title: Run Java applications on the Microsoft Azure Cobalt 100 processors
3+
4+
minutes_to_complete: 60
5+
6+
who_is_this_for: This is an introductory topic for the software developers who are willing to migrate their Java-based applications from x86_64 platforms to Arm-based platforms, or on Microsoft Azure - Cobalt 100 CPU-based VMs specifically. Most Java applications will run on Cobalt 100 with no changes needed.
7+
8+
learning_objectives:
9+
- Provision an Azure Arm64 VM using Azure console, with Ubuntu as the base image.
10+
- Learn how to create Azure Linux 3.0 Docker container.
11+
- Deploy a Java application inside an Azure Linux 3.0 Arm64-based Docker container, as well as Azure Linux 3.0 custom-image based Azure VM.
12+
- Perform Java benchmarking inside the container as well as the custom VM.
13+
14+
prerequisites:
15+
- A [Microsoft Azure](https://azure.microsoft.com/) account with access to Cobalt 100 based instances (Dpsv6).
16+
- A machine with [Docker](/install-guides/docker/) installed.
17+
18+
author: Zach Lasiuk
19+
20+
### Tags
21+
skilllevels: Advanced
22+
subjects: Performance and Architecture
23+
cloud_service_providers: Azure
24+
25+
armips:
26+
- Neoverse-N2
27+
28+
tools_software_languages:
29+
- Java
30+
- Docker
31+
32+
operatingsystems:
33+
- Linux
34+
35+
further_reading:
36+
- resource:
37+
title: Azure Virtual Machines documentation
38+
link: https://learn.microsoft.com/en-us/azure/virtual-machines/
39+
type: documentation
40+
- resource:
41+
title: Azure Container Instances documentation
42+
link: https://learn.microsoft.com/en-us/azure/container-instances/
43+
type: documentation
44+
- resource:
45+
title: Docker overview
46+
link: https://docs.docker.com/get-started/overview/
47+
type: documentation
48+
- resource:
49+
title: Java on Azure
50+
link: https://learn.microsoft.com/en-us/java/azure/
51+
type: documentation
52+
- resource:
53+
title: JMH (Java Microbenchmark Harness) documentation
54+
link: https://openjdk.org/projects/code-tools/jmh/
55+
type: documentation
56+
57+
58+
### FIXED, DO NOT MODIFY
59+
# ================================================================================
60+
weight: 1 # _index.md always has weight of 1 to order correctly
61+
layout: "learningpathall" # All files under learning paths have this same wrapper
62+
learning_path_main_page: "yes" # This should be surfaced when looking for related content. Only set for _index.md of learning path content.
63+
---
64+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
# ================================================================================
3+
# FIXED, DO NOT MODIFY THIS FILE
4+
# ================================================================================
5+
weight: 21 # Set to always be larger than the content in this path to be at the end of the navigation.
6+
title: "Next Steps" # Always the same, html page title.
7+
layout: "learningpathall" # All files under learning paths have this same wrapper for Hugo processing.
8+
---
9+
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
title: "Background"
3+
4+
weight: 2
5+
6+
layout: "learningpathall"
7+
---
8+
9+
## What is Cobalt 100 Arm-based processor?
10+
11+
Azure’s Cobalt 100 is built on Microsoft's first-generation, in-house Arm-based processor: the Cobalt 100. Designed entirely by Microsoft and based on Arm’s Neoverse N2 architecture, this 64-bit CPU delivers improved performance and energy efficiency across a broad spectrum of cloud-native, scale-out Linux workloads. These include web and application servers, data analytics, open-source databases, caching systems, and more. Running at 3.4 GHz, the Cobalt 100 processor allocates a dedicated physical core for each vCPU, ensuring consistent and predictable performance.
12+
13+
To learn more about Cobalt 100, refer to the blog [Announcing the preview of new Azure VMs based on the Azure Cobalt 100 processor](https://techcommunity.microsoft.com/blog/azurecompute/announcing-the-preview-of-new-azure-vms-based-on-the-azure-cobalt-100-processor/4146353).
14+
15+
## Introduction to Azure Linux 3.0
16+
17+
Azure Linux 3.0 is Microsoft's in-house, lightweight Linux distribution optimized for running cloud-native workloads on Azure. Designed with performance, security, and reliability in mind, it is fully supported by Microsoft and tailored for containers, microservices, and Kubernetes. With native support for Arm64 (Aarch64) architecture, Azure Linux 3.0 enables efficient execution of workloads on energy-efficient ARM-based infrastructure, making it a powerful choice for scalable and cost-effective cloud deployments.
18+
19+
As of now, the Azure Marketplace offers official VM images of Azure Linux 3.0 only for x64-based architectures, published by Ntegral Inc. However, native Arm64 (Aarch64) images are not yet officially available. Hence, for this Learning Path, we create our custom Azure Linux 3.0 VM image for Aarch64, using the [Aarch64 ISO for Azure Linux 3.0](https://github.com/microsoft/azurelinux#iso).
20+
21+
Alternatively, use the [Azure Linux 3.0 Docker container](https://learn.microsoft.com/en-us/azure/azure-linux/intro-azure-linux) on any supported platform.
22+
23+
For this Learning Path, we perform the deployment and benchmarking on both the Azure Linux 3.0 environments, the Docker container, as well as the custom-image-based VM.
24+
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
---
2+
title: Benchmarking via JMH
3+
weight: 5
4+
5+
### FIXED, DO NOT MODIFY
6+
layout: learningpathall
7+
---
8+
9+
## Test the Java application for Performance
10+
Now that you’ve built and run the Tomcat-like response, you can use it to test the JVM performance using JMH. You can also use it to test the performance difference between Cobalt 100 instances and other similar D series x86_64 based instances.
11+
As noted before, the steps to benchmark remain the same, whether it's a Docker container or a custom VM.
12+
13+
## Run the performance tests using JMH
14+
15+
JMH (Java Microbenchmark Harness) is a Java benchmarking framework developed by the JVM team at Oracle to measure the performance of small code snippets with high precision. It accounts for JVM optimizations like JIT and warm-up to ensure accurate and reproducible results. It measures the throughput, average latency, or execution time. Below steps help benchmark the Tomcat-like operation:
16+
17+
18+
Install Maven:
19+
20+
```console
21+
$ tdnf install maven -y
22+
```
23+
Create Benchmark Project:
24+
25+
```console
26+
$ mvn archetype:generate \
27+
-DinteractiveMode=false \
28+
-DarchetypeGroupId=org.openjdk.jmh \
29+
-DarchetypeArtifactId=jmh-java-benchmark-archetype \
30+
-DarchetypeVersion=1.37 \
31+
-DgroupId=com.example \
32+
-DartifactId=jmh-benchmark \
33+
-Dversion=1.0
34+
$ cd jmh-benchmark
35+
```
36+
37+
Edit the `src/main/java/com/example/MyBenchmark.java` file and add the below code on it:
38+
39+
```java
40+
package com.example;
41+
import org.openjdk.jmh.annotations.Benchmark;
42+
public class MyBenchmark {
43+
44+
@Benchmarkpublic void benchmarkHttpResponse() {
45+
String body = "Benchmarking a Tomcat-like operation";
46+
StringBuilder sb = new StringBuilder();
47+
sb.append("HTTP/1.1 200 OK\r\n");
48+
sb.append("Content-Type: text/plain\r\n");
49+
sb.append("Content-Length: ").append(body.length()).append("\r\n\r\n");
50+
sb.append(body);
51+
if (sb.length() == 0) throw new RuntimeException(); // avoid DCE }
52+
}
53+
```
54+
This simulates HTTP response generation similar to Tomcat.
55+
56+
Build the Benchmark:
57+
58+
```console
59+
$ mvn clean install
60+
```
61+
62+
After the build is complete, the JMH benchmark jar will be in the target/ directory.
63+
64+
Run the Benchmark:
65+
66+
```console
67+
$ java -jar target/benchmarks.jar
68+
```
69+
70+
71+
### Benchmark summary on x86_64:
72+
73+
The following benchmark results are collected on two different x86_64 environments: a **Docker container running Azure Linux 3.0 hosted on a D4s_v6 Ubuntu-based Azure VM**, and a **D4s_v4 Azure VM created from the Azure Linux 3.0 image published by Ntegral Inc**.
74+
75+
| Metric | Value on Docker Container | Value on Virtual Machine
76+
|----------------------------------|----------------------------------------|-------------------|
77+
| **Java Version** | OpenJDK 11.0.27 | OpenJDK 11.0.27 |
78+
| **Run Count** | 25 iterations | 25 iterations |
79+
| **Average Throughput** | 21.88M ops/sec | 15.39M ops/sec |
80+
| **Standard Deviation** | ±0.0769M ops/sec | ±0.17M ops/sec |
81+
| **Confidence Interval (99.9%)**| [21.82M, 21.94M] ops/sec | [14.97M, 15.58M] ops/sec
82+
83+
84+
### Benchmark summary on Arm64:
85+
86+
The following benchmark results are collected on two different Arm64 environments: a **Docker container running Azure Linux 3.0 hosted on a D4ps_v6 Ubuntu-based Azure VM**, and a **D4ps_v6 Azure VM created from the Azure Linux 3.0 custom image using the Aarch64 ISO**.
87+
88+
89+
| Metric | Value on Docker Container | Value on Virtual Machine
90+
|----------------------------------|----------------------------------------|-------------------|
91+
| **Java Version** | OpenJDK 11.0.27 | OpenJDK 11.0.27 |
92+
| **Run Count** | 25 iterations | 25 iterations |
93+
| **Average Throughput** | 35.60M ops/sec | 35.48M ops/sec |
94+
| **Standard Deviation** | ±0.1618M ops/sec | ±0.1918M ops/sec |
95+
| **Confidence Interval (99.9%)**| [35.48M, 35.72M] ops/sec | [35.347M, 35.62M] ops/sec
96+
97+
98+
### **Highlights from Azure Linux Arm64 Benchmarking (JDK 11.0.27)**
99+
100+
- **Superior Throughput:** Achieved an average of 35.60M ops/sec on Docker and 35.48M ops/sec on the virtual machine.
101+
- **Stable Performance:** Standard deviation on Docker is ±161,819.485 ops/sec and on the virtual machine is ±191,757.658 ops/sec, indicating consistent benchmarking results.
102+
- **Efficient Execution and Container Feasibility:** Demonstrates the efficiency of the Arm64 architecture for handling high-throughput Java workloads, even within a containerized Azure Linux environment.
103+
Loading

0 commit comments

Comments
 (0)