Skip to content

Document ConnectionPool behavior with different IP sets  #7675

Open
@costela

Description

@costela

I was a bit reluctant between a feature request and a bug, but since it's technically docummented, let's go with feature request for now.

We've run into some corner-case behavior which might warrant either some documentation improvement or maybe even some new feature. Context:

The documentation for ConnectionPool mentions this:

HTTP requests that share the same Address may share a Connection.

This means if we have two services whose DNS records point to some overlapping set of IPs (e.g. because they share a load-balancer), we might reuse a connection first used for service A when accessing service B later.
If we're using HTTP2 this can even happen over with TLS (HTTP1 would force a different connection to allow for SNI; HTTP2 can multiplex).

This seems like an unlikely scenario at first, but we ran into it while rolling out IPv6 support for some of our services:

  • our clients connect to a series of services in order
  • all services live behind a common HTTP2-capable load-balancer
  • one of them (S) was "dualstacked" before the others by getting an AAAA DNS record
  • service S actually needed the information "can this client speak IPv6?" (keeping the "why" out-of-scope; suffice to say it's the reason why it was prioritized over the other services)
  • service S almost never saw connections via v6 (even for clients we know had working v6 connectivity) 💥

Looking back it's clear we were reusing an existing v4 connection to some previous service to talk to a dualstacked service, which "shadowed" v6 support in almost all cases (except when we happened to run into connection-pool limits between calls).

I'm reluctanct to call this bug because in most cases an existing connection is what you want. However, I still see two possible improvements:

  1. expand the docs to include a mention to this edge case. Something like:

    "HTTP requests that share the same Address may share a Connection. Conversely, if one request resolves to address A, a subsequent request resolving to addresses A and B may never see any connections to address B."

  2. optionally extend the ip-to-connection mapping to consider all resolved IPs (becoming maybe "hash-of-ips"-to-connection?). This would incur some minor overhead at the advantage of ensuring connection reuse is tried only when it's sane.

wdyt?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementFeature not a bugneeds infoMore information needed from reporter

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions