Skip to content

Tunable HTTP Transport and Connection Pooling #64

@coolguy1771

Description

@coolguy1771

Proposal

The library currently relies on default HTTP transport settings, which limits our ability to optimize for high-scale environments. Without access to connection pool configurations like MaxIdleConns or IdleConnTimeout, users cannot tune the client to prevent socket exhaustion or optimize for high-throughput scaling events.

Proposed Changes

I suggest exposing a TransportConfig struct via a new HTTPOption. This allows users to override the underlying http.Transport settings without having to provide a fully custom http.Client.

type TransportConfig struct {
    MaxIdleConns        int
    MaxIdleConnsPerHost int
    IdleConnTimeout     time.Duration
    DisableKeepAlives   bool
}

func WithTransportConfig(config TransportConfig) HTTPOption {
    return func(c *httpClientOption) {
        c.transportConfig = &config
    }
}

Why this is needed

  • High-Scale Performance: In environments with thousands of runners, the default MaxIdleConnsPerHost (which is 2 in Go's default transport) can become a significant bottleneck, causing high latency due to constant connection recreation.
  • Resource Management: Custom IdleConnTimeout and MaxIdleConns allow better control over the memory footprint and open file descriptors on the host.
  • Flexibility: Provides a clean way to disable keep-alives or tune the transport for specific network topologies without leaking implementation details.

Implementation Note

The httpClientOption should apply these settings to the http.Transport during client initialization, falling back to sensible defaults if the config is not provided.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions