Java NIO Systems Engineering
501 req/s1.5ms p5099.8% success

NioFlow: A Configurable Java Micro-Framework.

NioFlow is a minimalistic Java HTTP framework focusing on explicit programmatic configuration. It utilizes a hybrid architecture: NIO Selector for connection acceptance and a bounded thread pool for blocking request processing.

nioflow_server — bash

$ npm install -g @jhanvi857/nioflow-cli

[INFO] nioflow: Linked global binary successfully.

$ nioflow dev

[INFO] Watcher: Monitoring src/main/java...

[INFO] Bootstrap: Starting NioFlow v1.4.0

[INFO] NIO: ServerSocketChannel on 0.0.0.0:8080

[READY] Application live with Hot Reload enabled.

$ curl http://localhost:8080/metrics

HTTP/1.1 200 OK

{ "req_total": 1205, "p95_ms": 47.7 }

Fast Track Installation

Get up and running in seconds. The NioFlow CLI manages your Java environment, dependencies, and project scaffolding so you can focus on building routes.

  • No manual JAR downloads required
  • Automatic Maven Wrapper integration
  • Cross-platform support (Windows, macOS, Linux)
Global Setupv1.4.0

# Install the CLI

npm install -g @jhanvi857/nioflow-cli

# Scaffold & Start

nioflow new my-app

cd my-app

nioflow dev

Production Resilience Pack

Stop worrying about infrastructure. NioFlow ships with native middleware for resilience and observability that you normally spend weeks configuring.

CHS

Chaos Injection

Validate frontend resilience by injecting latency and errors into your routes.

app.use(new ChaosMiddleware() .latency(200, 0.1));
CBR

Circuit Breaker

Fast-fail when downstream services are struggling to prevent cascading outages.

group.use(new CircuitBreaker() .threshold(0.5));
RPL

Request Replay

Record and replay production-like requests locally for rapid debugging.

app.enableReplay(50);

Audited for CVEs post-release. CRLF injection, XFF spoofing, JWT gaps, and HTTP request smuggling patched in v1.4.0.

Under the Hood: System Mechanics

Built on Java NIO and robust architectural patterns, NioFlow provides an incredibly fast, non-blocking foundation for building scalable web applications and RESTful APIs.

NIO

Hybrid NIO Architecture

Built on Java's java.nio. Connection tracking and event loops use efficient Selectors, while request processing is handled by a bounded worker pool.

TLS

Native HTTPS Security

Direct SSLContext integration allows raw SocketChannel handoffs to SSLSocketFactory, dropping the requirement for Nginx proxies entirely for HTTPS.

DMA

Zero-Copy Memory

Hardware-accelerated Direct Memory Access via FileChannel.transferTo(). Static files hit the socket without crossing into JVM user-space memory.

DB

Async Database Offload

Prevent worker thread blocking using CompletableFuture. Operations hit HikariCP and PostgreSQL on a dedicated secondary loop, ensuring maximum throughput.

HED

Request Hedging

Native tail-latency reduction. Automatically fire backup requests when primary executions cross latency thresholds to keep p99s consistently low.

OTEL

Observability Pack

Native OpenTelemetry tracing, Prometheus metrics, and structured JSON logging. Get full visibility into your distributed system with zero external agents.

Clean Controller Abstraction

While the engine is complex at the socket layer, registering business logic remains declarative and heavily typed. Look at how easy it is to spin up new HTTP endpoints.

ServerApp.java
1public class ServerApp {
2 public static void main(String[] args) {
3 // Automatically loads .env file using io.github.cdimascio:dotenv-java
4 NioFlowApp app = new NioFlowApp();
5
6 // Middleware Stack
7 app.use(new LoggerMiddleware());
8 app.use(new RateLimitMiddleware(100, Duration.ofMinutes(1)));
9
10 // Handlers & Async DB offload
11 app.get("/api/orders", new OrderController()::list);
12
13 // Global Error Intercept
14 app.onError((err, ctx) -> ctx.status(500).json("Fail"));
15
16 // Graceful Shutdown
17 Runtime.getRuntime().addShutdownHook(new Thread(() -> {
18 app.drainAndStop(30, TimeUnit.SECONDS);
19 }));
20
21 // Native TLS & Environment config
22 int port = Env.getAsInt("PORT", 8080);
23 app.listen(port);
24 }
25}
Available on GitHub

Built for engineers who want to understand the stack, not hide from it.

The framework avoids reflection and hidden dependency injection containers. Authored by Jhanvi Patel, NioFlow ensures all dependencies and middleware flows are explicit and predictable.

Verified Performance
Throughput
501.12req/s
p50 Latency
1.52ms
p99 Latency
74.62ms
Success Rate
99.84%
Hardware-validated via k6 v1.7.1 (100 VUs)

Available on Maven Central

Add NioFlow as a dependency in Maven, Gradle, or SBT

View on Maven Central
<dependency>
  <groupId>io.github.jhanvi857</groupId>
  <artifactId>nioflow-framework</artifactId>
  <version>1.4.0</version>
</dependency>