Deno Oak vs Springboot: Hello world performance comparison
--
In one of the previous article, where I compared Deno’s native HTTP server with spring, I got comments that the comparison wasn’t fair. Spring is a framework, therefore it should be compared with a framework on the Deno side: Oak, Express, Fastify, etc. A very valid point.
This article compares the popular framework for Deno, Oak, with spring. The test setup is the same: MacBook M1 with 16G RAM. Deno v1.31.2 is compared with spring 3.0.4 over Java 17.
The code is as follows:
Deno
import {
Application,
FlashServer,
Router,
} from "https://deno.land/x/oak/mod.ts";
const app = new Application({ serverConstructor: FlashServer });
const router = new Router();
router.get("/", (ctx) => ctx.response.body = "Hello world");
app.use(router.routes());
app.use(router.allowedMethods());
await app.listen({ port: 3000 });
Spring
package com.example.demo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.http.ResponseEntity;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.RestController;
@SpringBootApplication
@RestController
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
@GetMapping("/")
public String handleRequest() {
return "Hello World!";
}
}
The test runs a total of 5M requests for 25, 100, 200, and 300 concurrent connections. The testing tool is bombardier which is known to be very fast.
Let’s jump straight to the results.
It turned out to be a neck-to-neck competition. The offered RPS is almost the same for all levels of concurrency. Spring’s latency is generally better than Deno. However, Spring uses much more resources (CPU and memory).
WINNER: Both