Skip to content
Closed
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
3 changes: 3 additions & 0 deletions frameworks/Java/netty-fast/.sdkmanrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Enable auto-env through the sdkman_auto_env config
# Add key=value pairs of SDKs to use below
java=25-oracle
60 changes: 60 additions & 0 deletions frameworks/Java/netty-fast/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Netty (Fast / Minimal)

This is a Netty-based implementation for the TechEmpower Framework Benchmarks.
It is a minimal, high-performance HTTP/1.1 server built directly on Netty
primitives with a focus on correctness and low overhead.

The implementation uses real HTTP parsing, proper response headers, and
standards-compliant behavior while aggressively minimizing allocations and
framework abstractions.

## Tests

### Plaintext Test
Responds with a static plaintext message.

GET /plaintext

Response body:
Hello, World!

Content-Type:
text/plain

### JSON Test
Responds with a JSON-encoded object using a real JSON serializer.

GET /json

Response body:
{"message":"Hello, World!"}

Content-Type:
application/json

JSON serialization is performed using fastjson2.

## Implementation Notes

- HTTP/1.1 only
- Pipelining supported
- Uses Netty event loops and pooled buffers
- Minimal channel pipeline
- No framework abstractions beyond Netty itself
- Optimized for low allocation rate and high throughput
- Designed to match TechEmpower benchmark rules and expectations

This implementation is intended to demonstrate the maximum achievable
performance of Netty when used as a low-level HTTP server.

## Versions

- Java 24+ (tested with Java 24 / 25)
- Netty 4.2.x
- fastjson2

## References

- https://netty.io/
- https://github.com/netty/netty
- https://github.com/TechEmpower/FrameworkBenchmarks
24 changes: 24 additions & 0 deletions frameworks/Java/netty-fast/benchmark_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"framework": "netty-fast",
"tests": [{
"default": {
"json_url": "/json",
"plaintext_url": "/plaintext",
"port": 8080,
"approach": "Realistic",
"classification": "Platform",
"database": "None",
"framework": "netty-fast",
"language": "Java",
"flavor": "None",
"orm": "Raw",
"platform": "Netty",
"webserver": "None",
"os": "Linux",
"database_os": "Linux",
"display_name": "netty-fast",
"notes": "",
"versus": "netty-fast"
}
}]
}
15 changes: 15 additions & 0 deletions frameworks/Java/netty-fast/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[framework]
name = "netty-fast"

[main]
urls.plaintext = "/plaintext"
urls.json = "/json"
approach = "Realistic"
classification = "Platform"
database = "None"
database_os = "Linux"
os = "Linux"
orm = "Raw"
platform = "Netty"
webserver = "None"
versus = "netty-fast"
13 changes: 13 additions & 0 deletions frameworks/Java/netty-fast/netty-fast.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM maven:3.9-eclipse-temurin-25-noble as maven
WORKDIR /netty-fast
COPY pom.xml pom.xml
COPY src src
RUN mvn -q -DskipTests package

FROM eclipse-temurin:25-jre-noble
WORKDIR /netty-fast
COPY --from=maven /netty-fast/target/app.jar ./app.jar
COPY run_netty.sh ./run_netty.sh
RUN chmod +x ./run_netty.sh
EXPOSE 8080
ENTRYPOINT ["./run_netty.sh"]
101 changes: 101 additions & 0 deletions frameworks/Java/netty-fast/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>

<groupId>com.techempower</groupId>
<artifactId>netty-example</artifactId>
<version>0.1</version>

<properties>
<maven.compiler.source>24</maven.compiler.source>
<maven.compiler.target>24</maven.compiler.target>
<netty.version>4.2.0.Final</netty.version>
</properties>

<packaging>jar</packaging>

<dependencies>

<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
<version>${netty.version}</version>
</dependency>

<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-transport-native-epoll</artifactId>
<version>${netty.version}</version>
<classifier>linux-x86_64</classifier>
</dependency>

<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-transport-native-kqueue</artifactId>
<version>${netty.version}</version>
<classifier>osx-x86_64</classifier>
</dependency>

<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-transport-native-kqueue</artifactId>
<version>${netty.version}</version>
<classifier>osx-aarch_64</classifier>
</dependency>

<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-transport-native-io_uring</artifactId>
<version>${netty.version}</version>
<classifier>linux-x86_64</classifier>
</dependency>

<dependency>
<groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2</artifactId>
<version>2.0.53</version>
</dependency>

</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<debug>false</debug>
</configuration>
</plugin>

<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<finalName>app</finalName>
<archive>
<manifest>
<mainClass>hello.HelloWebServer</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<appendAssemblyId>false</appendAssemblyId>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>

</plugins>
</build>
</project>
14 changes: 14 additions & 0 deletions frameworks/Java/netty-fast/run_netty.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

# PROFILING: -XX:+UnlockDiagnosticVMOptions -XX:+DebugNonSafepoints
JAVA_OPTIONS="--enable-native-access=ALL-UNNAMED \
-Dio.netty.noUnsafe=false \
--sun-misc-unsafe-memory-access=allow \
--add-opens=java.base/java.lang=ALL-UNNAMED \
-XX:+UseNUMA \
-XX:+UseParallelGC \
-Dio.netty.buffer.checkBounds=false \
-Dio.netty.buffer.checkAccessible=false \
$@"

exec java $JAVA_OPTIONS -jar app.jar
19 changes: 19 additions & 0 deletions frameworks/Java/netty-fast/src/main/java/hello/Constants.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package hello;

import io.netty.util.AsciiString;
import io.netty.util.CharsetUtil;

public final class Constants {

public static final byte[] STATIC_PLAINTEXT = "Hello, World!".getBytes(CharsetUtil.UTF_8);
public static final int STATIC_PLAINTEXT_LEN = STATIC_PLAINTEXT.length;
public static final CharSequence PLAINTEXT_CLHEADER_VALUE =
AsciiString.cached(String.valueOf(STATIC_PLAINTEXT_LEN));

public static final CharSequence SERVER_NAME = AsciiString.cached("Netty");

public static final Message STATIC_MESSAGE = new Message("Hello, World!");

private Constants() {
}
}
Loading