CafFeind ⚡️

The caffeine-fueled Java web server that keeps pace with nginx in our latency and throughput tests.

Virtual threads, Undertow guts, obsessive profiling, and now a built-in metrics dashboard.

Why operators keep a can of CafFeind nearby

Quick Serve CLI Zero-config mode turns any directory into a static origin in seconds. `java -jar caffeind.jar --metrics` launches HTTP plus a JSON/HTML observability endpoint.
Built-in Dashboard The metrics listener serves both `/metrics` (JSON) and `/` (a modern HTML dashboard) so you get latency, TLS, cache, and JVM stats with no extra setup.
WordPress-ready Cache Memory- and disk-backed precompression, hot-path caching, and background compression designed to front WordPress or other dynamic stacks.
Virtual Threads Everywhere Java 25 virtual threads + Undertow I/O keep CafFeind cool at ~130k RPS, running neck and neck with nginx across our benchmarks.
Full Middleware Stack Compression (gzip/brotli/zstd), Caffeine caching, security headers, IP filtering, rate limiting, and per-vhost access/error logs—all configurable via YAML or the Quick Serve CLI.
Runtime Log Control Rotate or truncate access/error logs without a restart using the new `caffeind logging` CLI or the `/admin/logging` metrics endpoint—ideal for ops automation.
.htaccess & .htpasswd Ready Drop in Apache-style rewrite rules and Basic Auth files. CafFeind hot-watches them, supports CLI reloads, and keeps credential storage compatible with your existing tooling.
ACME & TLS 1.3 First-class support for Let’s Encrypt, hot reloadable certs, ALPN, and deep TLS metrics (protocol/cipher mix, resumption rate, expiry tracking).

Quick start

1. Build

mvn clean package

2. Launch in quick-serve mode

java -jar target/caffeind-0.1.0-SNAPSHOT.jar --metrics --dir ./public

Static files appear at http://localhost:8080. The dashboard lives at http://localhost:9090/, JSON at /metrics.

Prefer declarative configs?

server:
  host: 0.0.0.0
  port: 8080
  httpsPort: 8443

vhosts:
  - domains: ["*"]
    documentRoot: ./public
    routes:
      - path: "/*"
        handler: optimized-static

metrics:
  enabled: true
  port: 9090
  path: "/metrics"

Logging defaults

logging:
  startupLevel: INFO
  steadyStateLevel: WARN
  access:
    perVhost: true
    directory: logs/access
  error:
    perVhost: true
    directory: logs/error

Need to rotate or truncate logs on demand? Run caffeind logging rotate --target access (or hit /admin/logging on the metrics listener) and keep the service online.

Run with config

java -jar target/caffeind-0.1.0-SNAPSHOT.jar caf-feind.yml

Observability on tap

Metrics dashboard highlights

  • Latency (avg/min/max), status-class counters, request/response bytes
  • Per-site request and cache hit rate tracking
  • TLS handshakes by protocol & cipher suite + certificate expiry timeline
  • Connector stats (active connections, throughput) straight from Undertow
  • Direct buffer usage, heap footprint, thread counts, GC time
  • Log maintenance hooks—trigger rotations or truncations via `/admin/logging` or the CLI

Point Prometheus at `/metrics` or keep things light with the HTML view—both derive from the same collector.

Route handlers

Optimized Static
- path: "/*"
  handler: optimized-static
  root: /var/www/html
FastCGI (PHP-FPM)
- path: "/*.php"
  handler: fastcgi
  upstream: 127.0.0.1:9000
Reverse Proxy
- path: "/api/*"
  handler: reverse-proxy
  upstream: http://backend:8080
Health Checks
- path: "/health*"
  handler: health

Endpoints: /health, /health/live, /health/ready

TLS + ACME in one YAML block

defaults:
  tls:
    enabled: true
    provider: acme
    acme:
      email: admin@example.com
      domains:
        - example.com
        - "*.example.com"
      challengeType: http-01
      renewBeforeDays: 28

middleware:
  security:
    enabled: true
  compression:
    enabled: true

CafFeind provisions and renews certificates, reloads them live, and publishes TLS metrics so you always know which cipher suites your clients prefer.

Production tuning

JVM

java \
  -Xms2G -Xmx2G \
  -XX:+UseParallelGC \
  -XX:+UseCompactObjectHeaders \
  -jar target/caffeind-0.1.0-SNAPSHOT.jar caf-feind.yml

Environment overrides

export CAF_FEIND_SERVER_PORT=9090
export CAF_FEIND_CACHE_SIZE=20000
java -jar target/caffeind-0.1.0-SNAPSHOT.jar

Middleware presets

middleware:
  caching:
    enabled: true
    maxSize: 10000
    ttlSeconds: 600
  rateLimit:
    enabled: true
    requestsPerSecond: 150
  metrics:
    enabled: true
Powered by
CoffeeSprout builds and maintains CafFeind. Explore the team’s high-performance Java infrastructure work at coffeesprout.nl.