Skip to content

Run Java applications on the Microsoft Cobalt 100 processors #2095

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
title: Create an Arm based cloud VM using Microsoft Cobalt 100 CPU
weight: 3

### FIXED, DO NOT MODIFY
layout: learningpathall
---

## Introduction

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.

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.

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

#### Create an Arm-based Azure Virtual Machine

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.

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.

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.

![Instance Screenshot](./instance.png)

The VM should be ready and running; you can SSH into the VM using the PEM key, along with the Public IP details.

{{% notice Note %}}

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

{{% /notice %}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
---
title: Install the JDK and build an application
weight: 4

### FIXED, DO NOT MODIFY
layout: learningpathall
---


### Platform Overview
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.

### Working inside Azure Linux 3.0 Docker container
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
distribution created by Microsoft.
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.

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
and run the Java application inside the container, with the default JDK provided by the Microsoft team via Azure Linux 3.0 environment.

### Create Azure Linux 3.0 Docker Container
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.

To create a docker container, install docker, and then follow the below instructions:

```console
$ sudo docker run -it --rm mcr.microsoft.com/azurelinux/base/core:3.0
```

The default container startup command is bash. tdnf and dnf are the default package managers.

### Install Java

This Azure Linux 3.0 image does not include Java, so you need to install it.

First update tdnf:

```console
$ tdnf update -y
```
Then install java-devel:

```console
$ tdnf install -y java-devel
```

Java-devel installs both the default JRE and JDK provided by Azure Linux 3.0.

Check to ensure that the JRE is properly installed:

```console
$ java -version
```

**Your output will look like this:**

```output
openjdk version "11.0.27" 2025-04-15 LTS
OpenJDK Runtime Environment Microsoft-11371464 (build 11.0.27+6-LTS)
OpenJDK 64-Bit Server VM Microsoft-11371464 (build 11.0.27+6-LTS, mixed mode,
sharing)
```

**Check to ensure that the JDK is properly installed:**

```console
$ javac -version
```
Your output will look like this:

```output
javac 11.0.27
```

Set Java Environment Variable for Arm:

```console
$ export JAVA_HOME=/usr/lib/jvm/msopenjdk-11
$ export PATH=$JAVA_HOME/bin:$PATH
```

{{% notice Note %}}
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.
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).

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.
{{% /notice %}}

### Deploy a Java application with Tomcat-like operation
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),
and RESTful APIs written in Java.
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
takes to build the response string, helping evaluate raw Java execution efficiency before deploying heavier frameworks like Tomcat.
Create a file named `HttpSingleRequestTest.java`, and add the below content to it:

```java
public class HttpSingleRequestTest {
public static void main(String[] args) {
long startTime = System.nanoTime();
String response = generateHttpResponse("Tomcat baseline test on Arm64");
long endTime = System.nanoTime();
double durationInMicros = (endTime - startTime) / 1_000.0;
System.out.println("Response Generated:\n" + response);
System.out.printf("Response generation took %.2f microseconds.%n", durationInMicros);
}
private static String generateHttpResponse(String body) {
return "HTTP/1.1 200 OK\r\n" +
"Content-Type: text/plain\r\n" +
"Content-Length: " + body.length() + "\r\n\r\n" +
body;
}
}
```
Compile and Run Java program :

```console
$ javac HttpSingleRequestTest.java
$ java -Xms128m -Xmx256m -XX:+UseG1GC HttpSingleRequestTest
```

- -Xms128m sets the initial heap size for the Java Virtual Machine to 128 MB.
- -Xmx256m sets the maximum heap size for the JVM to 256 MB.
- -XX:+UseG1GC enables the G1 Garbage Collector (Garbage First GC), designed for low pause times and better performance in large heaps.

Output of java program on the Arm VM:
```output

$ javac HttpSingleRequestTest.java
$ java -Xms128m -Xmx256m -XX:+UseG1GC HttpSingleRequestTest
Response Generated:
HTTP/1.1 200 OK
Content-Type: text/plain
Content-Length: 29

Tomcat baseline test on Arm64
Response generation took 22125.79 microseconds.
```
Output summary:

- The program generated a fake HTTP 200 OK response with a custom message.
- It then measured and printed the time taken to generate that response (22125.79 microseconds).
- This serves as a basic baseline performance test of string formatting and memory handling on the JVM running on an Azure Arm64 instance.
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
---
title: Run Java applications on the Microsoft Azure Cobalt 100 processors

minutes_to_complete: 60

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.

learning_objectives:
- Provision an Azure Arm64 VM using Azure console, with Ubuntu as the base image.
- Learn how to create Azure Linux 3.0 Docker container.
- 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.
- Perform Java benchmarking inside the container as well as the custom VM.

prerequisites:
- A [Microsoft Azure](https://azure.microsoft.com/) account with access to Cobalt 100 based instances (Dpsv6).
- A machine with [Docker](/install-guides/docker/) installed.

author: Zach Lasiuk

### Tags
skilllevels: Advanced
subjects: Performance and Architecture
cloud_service_providers: Microsoft Azure

armips:
- Neoverse-N2

tools_software_languages:
- Java
- Docker

operatingsystems:
- Linux

further_reading:
- resource:
title: Azure Virtual Machines documentation
link: https://learn.microsoft.com/en-us/azure/virtual-machines/
type: documentation
- resource:
title: Azure Container Instances documentation
link: https://learn.microsoft.com/en-us/azure/container-instances/
type: documentation
- resource:
title: Docker overview
link: https://docs.docker.com/get-started/overview/
type: documentation
- resource:
title: Java on Azure
link: https://learn.microsoft.com/en-us/java/azure/
type: documentation
- resource:
title: JMH (Java Microbenchmark Harness) documentation
link: https://openjdk.org/projects/code-tools/jmh/
type: documentation


### FIXED, DO NOT MODIFY
# ================================================================================
weight: 1 # _index.md always has weight of 1 to order correctly
layout: "learningpathall" # All files under learning paths have this same wrapper
learning_path_main_page: "yes" # This should be surfaced when looking for related content. Only set for _index.md of learning path content.
---

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
# ================================================================================
# FIXED, DO NOT MODIFY THIS FILE
# ================================================================================
weight: 21 # Set to always be larger than the content in this path to be at the end of the navigation.
title: "Next Steps" # Always the same, html page title.
layout: "learningpathall" # All files under learning paths have this same wrapper for Hugo processing.
---

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
title: "Background"

weight: 2

layout: "learningpathall"
---

## What is Cobalt 100 Arm-based processor?

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.

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

## Introduction to Azure Linux 3.0

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.

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

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.

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.

Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
---
title: Benchmarking via JMH
weight: 5

### FIXED, DO NOT MODIFY
layout: learningpathall
---

## Test the Java application for Performance
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.
As noted before, the steps to benchmark remain the same, whether it's a Docker container or a custom VM.

## Run the performance tests using JMH

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:


Install Maven:

```console
$ tdnf install maven -y
```
Create Benchmark Project:

```console
$ mvn archetype:generate \
-DinteractiveMode=false \
-DarchetypeGroupId=org.openjdk.jmh \
-DarchetypeArtifactId=jmh-java-benchmark-archetype \
-DarchetypeVersion=1.37 \
-DgroupId=com.example \
-DartifactId=jmh-benchmark \
-Dversion=1.0
$ cd jmh-benchmark
```

Edit the `src/main/java/com/example/MyBenchmark.java` file and add the below code on it:

```java
package com.example;
import org.openjdk.jmh.annotations.Benchmark;
public class MyBenchmark {

@Benchmarkpublic void benchmarkHttpResponse() {
String body = "Benchmarking a Tomcat-like operation";
StringBuilder sb = new StringBuilder();
sb.append("HTTP/1.1 200 OK\r\n");
sb.append("Content-Type: text/plain\r\n");
sb.append("Content-Length: ").append(body.length()).append("\r\n\r\n");
sb.append(body);
if (sb.length() == 0) throw new RuntimeException(); // avoid DCE }
}
```
This simulates HTTP response generation similar to Tomcat.

Build the Benchmark:

```console
$ mvn clean install
```

After the build is complete, the JMH benchmark jar will be in the target/ directory.

Run the Benchmark:

```console
$ java -jar target/benchmarks.jar
```


### Benchmark summary on x86_64:

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

| Metric | Value on Docker Container | Value on Virtual Machine
|----------------------------------|----------------------------------------|-------------------|
| **Java Version** | OpenJDK 11.0.27 | OpenJDK 11.0.27 |
| **Run Count** | 25 iterations | 25 iterations |
| **Average Throughput** | 21.88M ops/sec | 15.39M ops/sec |
| **Standard Deviation** | ±0.0769M ops/sec | ±0.17M ops/sec |
| **Confidence Interval (99.9%)**| [21.82M, 21.94M] ops/sec | [14.97M, 15.58M] ops/sec


### Benchmark summary on Arm64:

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


| Metric | Value on Docker Container | Value on Virtual Machine
|----------------------------------|----------------------------------------|-------------------|
| **Java Version** | OpenJDK 11.0.27 | OpenJDK 11.0.27 |
| **Run Count** | 25 iterations | 25 iterations |
| **Average Throughput** | 35.60M ops/sec | 35.48M ops/sec |
| **Standard Deviation** | ±0.1618M ops/sec | ±0.1918M ops/sec |
| **Confidence Interval (99.9%)**| [35.48M, 35.72M] ops/sec | [35.347M, 35.62M] ops/sec


### **Highlights from Azure Linux Arm64 Benchmarking (JDK 11.0.27)**

- **Superior Throughput:** Achieved an average of 35.60M ops/sec on Docker and 35.48M ops/sec on the virtual machine.
- **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.
- **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.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.