Skip to content

Expose Pingora max_h2_streams for HTTP/2/h2c upstreams #208

Description

@yachnytskyi

Thank you for developing Pingap.

Pingap already supports HTTP/2 upstream connections through the alpn upstream setting. This also allows a cleartext HTTP/2/h2c connection when the upstream does not use TLS:

[upstreams.app]
addrs = ["127.0.0.1:8080"]
alpn = "H2"

However, Pingora’s PeerOptions::max_h2_streams option does not appear to be exposed through Pingap’s upstream configuration.

Pingora defines:

/// How many concurrent h2 streams are allowed in the same connection.
pub max_h2_streams: usize,

and its current default is:

max_h2_streams: 1,

Pingap’s UpstreamConf exposes alpn, connection timeouts, idle timeout, TCP keepalive and related options. When constructing an upstream HttpPeer, Pingap assigns:

p.options.alpn = self.alpn.clone();

but does not assign p.options.max_h2_streams.

This means that an HTTP/2 or h2c upstream appears to retain Pingora’s default of one concurrent stream per connection. That prevents users from configuring practical HTTP/2 multiplexing between Pingap and an application backend.

Proposed configuration

Please consider adding an optional upstream setting:

[upstreams.app]
addrs = ["127.0.0.1:8080"]
alpn = "H2"
max_h2_streams = 100

For example, it could be represented in UpstreamConf as:

pub max_h2_streams: Option<usize>,

stored in the Pingap Upstream structure and applied when constructing the peer:

if let Some(max_h2_streams) = self.max_h2_streams {
    p.options.max_h2_streams = max_h2_streams;
}

Keeping the option optional would preserve the existing Pingora default and backward compatibility.

Requested scope

  • Add max_h2_streams to UpstreamConf.
  • Validate that the configured value is greater than zero.
  • Store and apply it to HttpPeer.options.max_h2_streams.
  • Expose it through Pingap’s web administration interface.
  • Add English and Chinese field descriptions.
  • Document it in the upstream configuration examples.
  • Add configuration parsing and serialization tests.
  • Add a test verifying that the configured value reaches the generated HttpPeer.

Motivation

This would be useful for:

  • Axum and other h2c application backends.
  • gRPC and Connect RPC services.
  • Concurrent or long-lived streaming requests.
  • Reducing the number of upstream TCP connections.
  • Receiving the main multiplexing benefit of HTTP/2 instead of limiting every connection to one active stream.

Relevant code:

Would you consider exposing this option?

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions