CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/maven-software-amazon-awssdk--netty-nio-client

A non-blocking HTTP client implementation for AWS SDK Java applications using Netty framework, enabling efficient network communication with AWS services through asynchronous I/O operations

Overview
Eval results
Files

http2-config.mddocs/

HTTP/2 Configuration

HTTP/2 protocol-specific configuration options for stream management, window sizes, and connection health monitoring in the NettyNioAsyncHttpClient.

Capabilities

Http2Configuration

Configuration class for HTTP/2 specific settings including stream limits, window sizes, and health check parameters.

/**
 * Http2Configuration provides HTTP/2 protocol-specific settings for NettyNioAsyncHttpClient.
 * Configures stream concurrency, flow control, and connection health monitoring.
 */
public final class Http2Configuration implements ToCopyableBuilder<Http2Configuration.Builder, Http2Configuration> {
    /**
     * Returns the maximum number of concurrent streams per HTTP/2 connection
     * @return maximum concurrent streams (default: Long.MAX_VALUE)
     */
    public Long maxStreams();
    
    /**
     * Returns the initial window size for HTTP/2 streams in bytes
     * @return initial window size (default: 65535 bytes per RFC 7540)
     */
    public Integer initialWindowSize();
    
    /**
     * Returns the period for sending health check PING frames
     * @return health check ping period (default: null - no health checks)
     */
    public Duration healthCheckPingPeriod();
    
    /**
     * Creates a new builder from this configuration
     * @return builder initialized with current values
     */
    public Builder toBuilder();
    
    /**
     * Creates a new builder instance
     * @return new Builder for HTTP/2 configuration
     */
    public static Builder builder();
    
    /**
     * Standard equals implementation
     */
    public boolean equals(Object obj);
    
    /**
     * Standard hashCode implementation
     */
    public int hashCode();
}

Usage Examples:

import software.amazon.awssdk.http.nio.netty.Http2Configuration;
import software.amazon.awssdk.http.nio.netty.NettyNioAsyncHttpClient;

// Basic HTTP/2 configuration
Http2Configuration http2Config = Http2Configuration.builder()
    .maxStreams(100L)
    .initialWindowSize(1024 * 1024)  // 1MB
    .healthCheckPingPeriod(Duration.ofSeconds(30))
    .build();

// Use with HTTP client
NettyNioAsyncHttpClient client = NettyNioAsyncHttpClient.builder()
    .protocol(Protocol.HTTP2)
    .http2Configuration(http2Config)
    .build();

// Consumer-based configuration
NettyNioAsyncHttpClient client = NettyNioAsyncHttpClient.builder()
    .protocol(Protocol.HTTP2)
    .http2Configuration(builder -> builder
        .maxStreams(50L)
        .initialWindowSize(512 * 1024)
        .healthCheckPingPeriod(Duration.ofMinutes(1)))
    .build();

Http2Configuration Builder

Builder interface for configuring HTTP/2 specific parameters.

/**
 * Builder for configuring HTTP/2 specific parameters
 */
public interface Builder extends CopyableBuilder<Builder, Http2Configuration> {
    /**
     * Sets the maximum number of concurrent streams per HTTP/2 connection.
     * This limits how many requests can be multiplexed over a single connection.
     * 
     * @param maxStreams maximum concurrent streams (must be positive, default: Long.MAX_VALUE)
     * @return this builder for method chaining
     */
    Builder maxStreams(Long maxStreams);
    
    /**
     * Sets the initial window size for HTTP/2 stream flow control in bytes.
     * This controls the initial amount of data that can be sent without flow control.
     * Must comply with RFC 7540 requirements (between 65535 and 2^31-1).
     * 
     * @param initialWindowSize initial window size in bytes (default: 65535)
     * @return this builder for method chaining
     */
    Builder initialWindowSize(Integer initialWindowSize);
    
    /**
     * Sets the period for sending HTTP/2 PING frames for connection health monitoring.
     * When set, the client will periodically send PING frames to detect connection issues.
     * 
     * @param healthCheckPingPeriod ping period duration (null disables health checks)
     * @return this builder for method chaining
     */
    Builder healthCheckPingPeriod(Duration healthCheckPingPeriod);
    
    /**
     * Builds the HTTP/2 configuration instance
     * @return configured Http2Configuration
     */
    Http2Configuration build();
}

Configuration Examples:

// High-throughput configuration
Http2Configuration highThroughput = Http2Configuration.builder()
    .maxStreams(200L)                          // Allow 200 concurrent streams
    .initialWindowSize(2 * 1024 * 1024)        // 2MB initial window
    .healthCheckPingPeriod(Duration.ofSeconds(15))  // Ping every 15 seconds
    .build();

// Conservative configuration for unreliable networks
Http2Configuration conservative = Http2Configuration.builder()
    .maxStreams(10L)                           // Limit to 10 concurrent streams
    .initialWindowSize(64 * 1024)              // 64KB initial window
    .healthCheckPingPeriod(Duration.ofSeconds(5))   // Frequent health checks
    .build();

// Disable health checks
Http2Configuration noHealthChecks = Http2Configuration.builder()
    .maxStreams(100L)
    .initialWindowSize(1024 * 1024)
    .healthCheckPingPeriod(null)               // No health check pings
    .build();

// Copy and modify existing configuration
Http2Configuration modified = existingConfig.toBuilder()
    .maxStreams(150L)                          // Change only max streams
    .build();

HTTP/2 Performance Tuning

Stream Concurrency

The maxStreams setting controls how many HTTP requests can be multiplexed over a single HTTP/2 connection:

// For high-throughput scenarios
Http2Configuration.builder()
    .maxStreams(500L)  // Allow many concurrent streams
    .build();

// For memory-constrained environments
Http2Configuration.builder()
    .maxStreams(20L)   // Limit concurrent streams
    .build();

Flow Control Window Size

The initialWindowSize affects throughput and memory usage:

// Large window for high-bandwidth connections
Http2Configuration.builder()
    .initialWindowSize(4 * 1024 * 1024)  // 4MB - higher throughput, more memory
    .build();

// Small window for bandwidth-limited connections
Http2Configuration.builder()
    .initialWindowSize(64 * 1024)        // 64KB - lower memory, may limit throughput
    .build();

Connection Health Monitoring

Health check pings help detect broken connections:

// Aggressive health checking for critical applications
Http2Configuration.builder()
    .healthCheckPingPeriod(Duration.ofSeconds(10))
    .build();

// Conservative health checking to reduce overhead
Http2Configuration.builder()
    .healthCheckPingPeriod(Duration.ofMinutes(2))
    .build();

// Disable health checking (rely on other mechanisms)
Http2Configuration.builder()
    .healthCheckPingPeriod(null)
    .build();

Integration with HTTP Client

Protocol Selection

HTTP/2 configuration only applies when HTTP/2 protocol is selected:

NettyNioAsyncHttpClient client = NettyNioAsyncHttpClient.builder()
    .protocol(Protocol.HTTP2)              // Must specify HTTP/2
    .protocolNegotiation(ProtocolNegotiation.ALPN)  // Use ALPN negotiation
    .http2Configuration(Http2Configuration.builder()
        .maxStreams(100L)
        .initialWindowSize(1024 * 1024)
        .build())
    .build();

ALPN vs Prior Knowledge

Protocol negotiation affects how HTTP/2 is established:

// ALPN negotiation (recommended for HTTPS)
NettyNioAsyncHttpClient client = NettyNioAsyncHttpClient.builder()
    .protocol(Protocol.HTTP2)
    .protocolNegotiation(ProtocolNegotiation.ALPN)  // Negotiate during TLS handshake
    .http2Configuration(http2Config)
    .build();

// Prior knowledge (for known HTTP/2 servers)
NettyNioAsyncHttpClient client = NettyNioAsyncHttpClient.builder()
    .protocol(Protocol.HTTP2)
    .protocolNegotiation(ProtocolNegotiation.ASSUME_PROTOCOL)  // Assume HTTP/2
    .http2Configuration(http2Config)
    .build();

Types

HTTP/2 Protocol Types

enum Protocol {
    HTTP1_1,  // HTTP/1.1 protocol
    HTTP2     // HTTP/2 protocol
}

enum ProtocolNegotiation {
    ALPN,              // Application Layer Protocol Negotiation (RFC 7301)
    ASSUME_PROTOCOL    // Assume configured protocol without negotiation
}

Builder Pattern Types

interface ToCopyableBuilder<B extends CopyableBuilder<B, T>, T> {
    B toBuilder();
}

interface CopyableBuilder<B extends CopyableBuilder<B, T>, T> {
    T build();
}

Duration Type

// Standard Java duration type for time-based configurations
class Duration {
    static Duration ofSeconds(long seconds);
    static Duration ofMillis(long millis);
    static Duration ofMinutes(long minutes);
    static Duration ofHours(long hours);
    
    long toSeconds();
    long toMillis();
}

HTTP/2 Specification Compliance

The Http2Configuration follows RFC 7540 (HTTP/2) specifications:

  • Initial Window Size: Must be between 65,535 bytes (default) and 2^31-1 bytes
  • Stream Concurrency: Controlled by SETTINGS_MAX_CONCURRENT_STREAMS
  • Flow Control: Implements HTTP/2 flow control mechanisms
  • Health Checks: Uses HTTP/2 PING frames for connection validation

Install with Tessl CLI

npx tessl i tessl/maven-software-amazon-awssdk--netty-nio-client

docs

event-loop.md

http-client.md

http2-config.md

index.md

proxy-config.md

tile.json