Skip to content

Benchmark

Bernardusz edited this page Jun 9, 2026 · 1 revision

πŸš€ Performance Benchmarks

Levtus is optimized for extreme throughput and minimal resource footprint by combining Project Loom (Virtual Threads) with GraalVM Native Image technology.

πŸ“ Benchmark Code

The following "Hello World" application was used for all tests. It includes standard DoS protection settings and static file configuration.

import io.github.bernardusz.levtus.Levtus;

void main(){
  Levtus app = Levtus.create();

  app.maxConcurrentConnections(500)
    .maxBodySize(1024 * 1024)
    .maxHeaderCount(50)
    .maxHeaderSize(4096)
    .maxLineSize(4096)
    .maxEmptyLines(3)
    .staticFiles("public");

  app.get("/", ctx -> {
    ctx.text("An incoming " + ctx.req().method() + "request!" );
  });

  app.post("/", ctx -> {
    ctx.text(ctx.req().body().toString());
    ctx.status(200).contentType("text/plain").send("Created!");
  });

  app.put("/", ctx -> {
    ctx.text(ctx.req().body().toString());
  });

  app.delete("/", ctx -> {
    ctx.text("Deleted successfully!");
  });

  app.listen(8080);
}

πŸ“Š Summary Comparison

Metric JVM (Fat Jar) GraalVM Native
Throughput (RPS) ~209,223 ~160,998
Idle RAM ~45.6 MB 11-13 MB
Peak RAM ~310 MB 114 MB
Binary Size ~38 KB (jar) ~16.7 MB

⚑ 1. GraalVM Native Image

Best for: High-density microservices, Serverless, and CLI tools.

Build Information

  • Binary Size: 16.71 MB
  • Build Time: 1m 5s
  • Peak Build RSS: 1.78 GB

Performance (wrk)

Tested with 4 threads and 400 concurrent connections over 30 seconds.

Requests/sec: 160,998.28
Transfer/sec:  16.74 MB

Latency Distribution:
  50%    1.68ms
  75%    4.04ms
  90%    6.55ms
  99%   15.28ms
  Max   98.06ms

Resource Usage (htop)

  • Idle: ~12.0 MB
  • Peak: ~114 MB

Native Image Idle Idle footprint at ~12MB


πŸ”₯ 2. JVM Mode (Fat Jar)

Best for: High-traffic core services requiring maximum throughput.

Performance (wrk)

Tested with 4 threads and 400 concurrent connections over 30 seconds.

Requests/sec: 209,223.55
Transfer/sec:  21.75 MB

Latency Distribution:
  50%    1.04ms
  75%    3.07ms
  90%    5.30ms
  99%   12.11ms
  Max  206.83ms

Resource Usage (htop)

  • Idle: ~45.6 MB
  • Peak: ~310 MB

JVM Idle Idle footprint at ~45MB


πŸ’‘ Key Takeaways

  1. Go-Level Efficiency: In Native Image mode, Levtus achieves an idle RAM footprint of 11-13 MB, putting it on par with Go for resource efficiency while maintaining the power of the Java ecosystem.
  2. Loom Scaling: Handling 400 concurrent connections with a median latency as low as 1.04ms demonstrates the lightweight nature of Virtual Threads compared to traditional thread pools.
  3. Deployment Flexibility:
    • Native Image: Provides near-instant startup (<10ms) and minimal RAM, perfect for containerized environments.
    • JVM Mode: Provides higher raw throughput (~200k+ RPS) by utilizing the Graal JIT compiler's advanced runtime optimizations.

⌨ Raw Temrinal Data

GraalVM compilation

bernardus@DESKTOP-3HNT5JD:~/projects/web/levtus.wiki/levtus-test/target$ native-image -jar levtus-test-1.0-SNAPSHOT.jar
========================================================================================================================
GraalVM Native Image: Generating 'levtus-test-1.0-SNAPSHOT' (executable)...
========================================================================================================================
[1/8] Initializing...                                                                                    (5.5s @ 0.12GB)
 Java version: 25.0.3+9-LTS, vendor version: Oracle GraalVM 25.0.3+9.1
 Graal compiler: optimization level: 2, target machine: x86-64-v3, PGO: ML-inferred
 C compiler: gcc (linux, x86_64, 13.3.0)
 Garbage collector: Serial GC (max heap size: 80% of RAM)
 1 user-specific feature(s):
 - com.oracle.svm.thirdparty.gson.GsonFeature
------------------------------------------------------------------------------------------------------------------------
Build resources:
 - 6.27GB of memory (75.6% of system memory, less than 8GB of memory available)
 - 8 thread(s) (100.0% of 8 available processor(s), determined at start)
[2/8] Performing analysis...  [*****]                                                                   (13.6s @ 0.49GB)
    3,694 types,   4,250 fields, and  19,620 methods found reachable
    1,191 types,      40 fields, and   1,098 methods registered for reflection
       59 types,      59 fields, and      53 methods registered for JNI access
        0 downcalls and 0 upcalls registered for foreign access
        4 native libraries: dl, pthread, rt, z
[3/8] Building universe...                                                                               (1.7s @ 0.54GB)
[4/8] Parsing methods...      [**]                                                                       (3.9s @ 0.59GB)
[5/8] Inlining methods...     [***]                                                                      (0.9s @ 0.63GB)
[6/8] Compiling methods...    [******]                                                                  (33.6s @ 0.60GB)
[7/8] Laying out methods...   [**]                                                                       (2.5s @ 0.70GB)
[8/8] Creating image...       [**]                                                                       (2.3s @ 0.78GB)
   7.15MB (40.31%) for code area:    10,302 compilation units
   8.52MB (48.00%) for image heap:  135,570 objects and 55 resources
   2.07MB (11.69%) for other data
  17.75MB in total image size, 16.71MB in total file size
------------------------------------------------------------------------------------------------------------------------
Top 10 origins of code area:                                Top 10 object types in image heap:
   4.86MB java.base                                            1.91MB byte[] for code metadata
   1.66MB svm.jar (Native Image)                               1.40MB byte[] for java.lang.String
 116.00kB java.logging                                       820.10kB java.lang.String
  69.05kB levtus-test-1.0-SNAPSHOT.jar                       472.94kB heap alignment
  59.77kB com.oracle.svm.svm_enterprise                      460.86kB byte[] for general heap data
  48.81kB org.graalvm.nativeimage.configure                  452.54kB java.lang.Class
  40.29kB jdk.graal.compiler                                 384.18kB com.oracle.svm.core.hub.DynamicHubCompanion
  36.69kB org.graalvm.nativeimage.base                       361.34kB java.util.concurrent.ConcurrentHashMap$Node
  21.62kB jdk.internal.vm.ci                                 268.70kB java.util.HashMap$Node
  21.14kB jdk.net                                            250.07kB java.lang.Object[]
  62.59kB for 8 more packages                                  1.74MB for 1071 more object types
                            Use '--emit build-report' to create a report with more details.
------------------------------------------------------------------------------------------------------------------------
Security report:
 - Binary includes Java deserialization.
 - CycloneDX SBOM with 7 component(s) is embedded in binary (519B).
 - Advanced obfuscation not enabled; enable with '-H:AdvancedObfuscation=""' (experimental support).
------------------------------------------------------------------------------------------------------------------------
Recommendations:
 G1GC: Use the G1 GC ('--gc=G1') for improved latency and throughput.
 PGO:  Use Profile-Guided Optimizations ('--pgo') for improved throughput.
 FUTR: Use '--future-defaults=all' to prepare for future releases.
 HEAP: Set max heap for improved and more predictable memory usage.
 CPU:  Enable more CPU features with '-march=native' for improved performance.
------------------------------------------------------------------------------------------------------------------------
                       5.0s (7.5% of total time) in 1208 GCs | Peak RSS: 1.78GB | CPU load: 6.47
------------------------------------------------------------------------------------------------------------------------
Build artifacts:
 /home/bernardus/projects/web/levtus.wiki/levtus-test/target/levtus-test-1.0-SNAPSHOT (executable)
========================================================================================================================
Finished generating 'levtus-test-1.0-SNAPSHOT' in 1m 5s.

Target size

bernardus@DESKTOP-3HNT5JD:~/projects/web/levtus.wiki/levtus-test/target$ ls -lh
total 16M
drwxr-xr-x 2 bernardus bernardus 4.0K Jun  9 17:18 classes
drwxr-xr-x 3 bernardus bernardus 4.0K Jun  9 17:18 generated-sources
-rwxr-xr-x 1 bernardus bernardus  16M Jun  9 17:22 levtus-test-1.0-SNAPSHOT -> Graal VM Binary
-rw-r--r-- 1 bernardus bernardus  38K Jun  9 17:19 levtus-test-1.0-SNAPSHOT.jar -> Fat Jar
drwxr-xr-x 2 bernardus bernardus 4.0K Jun  9 17:18 maven-archiver
drwxr-xr-x 3 bernardus bernardus 4.0K Jun  9 17:18 maven-status
-rw-r--r-- 1 bernardus bernardus 3.3K Jun  9 17:18 original-levtus-test-1.0-SNAPSHOT.jar
bernardus@DESKTOP-3HNT5JD:~/projects/web/levtus.wiki/levtus-test/target$ ./levtus-test-1.0-SNAPSHOT 
πŸš€ Levtus Engine started on port 8080 (HTTP)

Htop Idle (GraalVM)

  28729 bernardus   20   0 32.1G 12012 10744 S   0.0  0.1  0:00.00 ./levtus-test-1.0-SNAPSHOT                                                                              

alt text

Htop Peak (GraalVM)

bernardus@DESKTOP-3HNT5JD:~/projects/web/levtus.wiki/levtus-test/target$ wrk -t4 -c400 -d30s --latency http://localhost:8080
Running 30s test @ http://localhost:8080
  4 threads and 400 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     2.93ms    3.98ms  98.06ms   91.10%
    Req/Sec    40.54k    11.46k   88.99k    75.08%
  Latency Distribution
     50%    1.68ms
     75%    4.04ms
     90%    6.55ms
     99%   15.28ms
  4843143 requests in 30.08s, 503.45MB read
Requests/sec: 160998.28
Transfer/sec:     16.74MB

alt text

Htop Idle - Fat JAR (OpenJDK - 25)

bernardus@DESKTOP-3HNT5JD:~/projects/web/levtus.wiki/levtus-test$ java -jar target/levtus-test-1.0-SNAPSHOT.jar
πŸš€ Levtus Engine started on port 8080 (HTTP)
  23906 bernardus   20   0 4688M 45624 26316 S   0.0  0.6  0:00.00 java -jar target/levtus-test-1.0-SNAPSHOT.jar                                                                                                                                                                                                                                           

alt text

Htop Peak - Fat JAR (OpenJDK - 25)

bernardus@DESKTOP-3HNT5JD:~/projects/web/levtus.wiki$ wrk -t4 -c400 -d30s --latency http://localhost:8080
Running 30s test @ http://localhost:8080
  4 threads and 400 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     2.18ms    2.72ms 206.83ms   88.14%
    Req/Sec    52.75k    16.45k  124.01k    73.74%
  Latency Distribution
     50%    1.04ms
     75%    3.07ms
     90%    5.30ms
     99%   12.11ms
  6292708 requests in 30.08s, 654.13MB read
Requests/sec: 209223.55
Transfer/sec:     21.75MB

alt text

Video for proof of benchmark coming soon.

🐧 Getting Started

🧩 Core API

πŸ“¦ Features

πŸ›‘οΈ Security & Stability

πŸš€ Performance & Deployment

🀝 Project

Clone this wiki locally