Apache Tomcat is a widely used Java web application server. Technically, it is a Servlet container, responsible for executing Java servlets and supporting technologies such as:
In production, frameworks like Tomcat introduce additional complexity (such as request parsing, thread management, and I/O handling). Before layering those components, it’s useful to measure how efficiently raw Java executes simple request/response logic on Azure Cobalt 100 Arm-based instances.
In this section, you will run a minimal Tomcat-like simulation. It won’t launch a real server, but instead it will do the following:
Using a file editor of your choice, create a file named HttpSingleRequestTest.java
, and add the content below to it:
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 the program and run it with modest heap sizes and the G1 garbage collector:
javac HttpSingleRequestTest.java
java -Xms128m -Xmx256m -XX:+UseG1GC HttpSingleRequestTest
If the program runs successfully, you should see output similar to the following:
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 12901.53 microseconds.
For repeatable baselines on Azure Cobalt 100, keep other workloads off the VM, use consistent power settings, and keep OS/JDK versions fixed during comparisons. For statistics and warmups, wrap this code with JMH.