Skip to content

SouradipPatra7904/PrimRoseHTTP

Repository files navigation

PrimRoseHTTP

A high-performance, event-driven, multithreaded HTTP 1.1 server built with Netty and Java.

PrimRoseHTTP is designed for low-level control, high concurrency, and Prometheus-compatible metrics, with a browser-friendly dashboard.


Features

  • Non-blocking, event-driven architecture using Netty
  • Multi-handler pipeline:
    • / → Index page
    • /hello → Hello World
    • /about → Developer Information
    • /metrics → Prometheus metrics
    • /metrics-dashboard → Live HTML metrics dashboard with auto-refresh and charts
    • All other paths → 404 Not Found
  • Metrics monitoring:
    • Total HTTP requests
    • Active connections
  • Browser-friendly dashboard using plain javascript
  • Unit-tested using JUnit 5 and Netty EmbeddedChannel
  • Maven build with Shade plugin for runnable fat JAR
  • Javadoc generation for full documentation

Requirements

  • Java 17+
  • Maven 3.6+

Getting Started

Clone the repository

git clone https://github.com/SouradipPatra7904/PrimRoseHTTP
cd PrimRoseHTTP

Build the project

mvn clean package

This generates a runnable fat JAR:

target/primrose_http_server-1.0-SNAPSHOT.jar

Run the server

Default port 8080:

java -jar target/primrose_http_server-1.0-SNAPSHOT.jar

Custom port:

java -jar target/primrose_http_server-1.0-SNAPSHOT.jar 9090

Test the endpoints


Run unit tests

mvn clean test
  • All handlers are tested using Netty EmbeddedChannel
  • /metrics endpoint is fully covered

Metrics

Prometheus-compatible metrics:

# HELP http_total_requests Total number of HTTP requests
# TYPE http_total_requests counter
http_total_requests 10

# HELP http_active_connections Current number of active connections
# TYPE http_active_connections gauge
http_active_connections 2

Browser dashboard:

  • Displays metrics in bar charts
  • Auto-refreshes every 5 seconds
  • Shows both total requests and active connections
  • Includes link to raw /metrics endpoint

Build & Packaging

  • Maven Shade Plugin creates a runnable fat JAR
  • Javadoc plugin generates API documentation:
mvn javadoc:javadoc

Advanced Concepts Used

  • Netty EventLoopGroup for multi-threaded, non-blocking IO
  • Pipeline design pattern for modular request handling
  • FullHttpRequest aggregation using HttpObjectAggregator
  • Atomic metrics for thread-safe counters
  • EmbeddedChannel for unit testing without a live server
  • Chart.js integration for live metrics visualization
  • Prometheus exposition format for observability
  • Maven build lifecycle with Surefire, JaCoCo, and Shade

Configuration

  • application.properties holds configurable parameters:
    • Server port
    • Max connections
    • Optional timeouts
  • .gitignore excludes sensitive files and build directories
  • A sample file application.properties.example is provided for reference

Notes

  • Metrics endpoints are safe for Prometheus scraping and human-friendly viewing
  • The pipeline order ensures /metrics and /metrics-dashboard are handled before other handlers
  • Auto-refresh dashboard makes it easy to monitor server activity in real time

PrimRoseHTTP combines low-level performance with developer-friendly metrics and testing, making it a solid foundation for high-concurrency HTTP services.

About

A minimal HTTP Server implemented in Java-17 & Netty-4, built with Maven.

Topics

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors