ZIO Quartz H2
ZIO Quartz H2 is a high-performance HTTP/2 server built on ZIO, providing both HTTP/1.1 and HTTP/2 protocol support with various connection modes.
Server Architecture Overview
ZIO Quartz H2 is designed with flexibility and performance in mind, supporting multiple connection modes and protocols:
Connection Modes
- Asynchronous NIO Mode - Uses Java NIO for non-blocking I/O operations with asynchronous channel groups
- Synchronous Socket Mode - Uses traditional Java Socket API for synchronous connections
- Linux io_uring Mode - Leverages Linux's io_uring interface for high-performance I/O operations (Linux-specific)
Protocol Support
- HTTP/2 with TLS (h2) - Full HTTP/2 protocol support over TLS connections
- HTTP/2 Clear Text (h2c) - HTTP/2 protocol support without encryption
- HTTP/1.1 - Backward compatibility with HTTP/1.1 protocol
- Protocol Upgrade - Support for upgrading HTTP/1.1 connections to HTTP/2
Connection Flow
The server handles connections through the following process:
- Accept incoming connection (TCP or TLS)
- Detect protocol (HTTP/1.1 or HTTP/2)
- For HTTP/2: Process preface and establish HTTP/2 connection
- For HTTP/1.1: Process as HTTP/1.1 or attempt upgrade to HTTP/2 if requested
- Route requests to appropriate handlers
- Stream responses back to clients
Key Components
QuartzH2Server
The main server component that handles:
- Server initialization and configuration
- Connection acceptance and management
- Protocol detection and switching
- Multiple startup modes (NIO, Socket, io_uring)
Http2Connection
Manages HTTP/2 connections with features like:
- Stream multiplexing
- Flow control
- Header compression
- Server push capability
Http11Connection
Handles HTTP/1.1 connections with support for:
- Keep-alive connections
- Chunked transfer encoding only - HTTP/1.1 responses use chunked encoding exclusively with ZStream, the Content-Length header variable is not used
- Protocol upgrade to HTTP/2
- Compatibility with existing HTTP/1.1 clients
IOChannel Implementations
Different I/O channel implementations:
TCPChannel
- For NIO-based connections
SocketChannel
- For Socket-based connections
TLSChannel
- For secure connections with SSL/TLS
IOURingChannel
- For Linux io_uring-based connections
Performance Features
- Stream Multiplexing - Multiple requests over a single connection
- Efficient Resource Usage - Configurable thread pools and connection limits
- Linux io_uring Support - High-performance I/O operations on Linux systems
- ZIO Integration - Leverages ZIO's effect system for concurrency and resource management
- Configurable Timeouts - Idle connection timeouts to manage resources
- Flow Control - Prevents overwhelming clients with data
Documentation
Explore the documentation to learn more about ZIO Quartz H2: