Skip to content

Conversation

@u5surf
Copy link
Contributor

@u5surf u5surf commented Sep 30, 2025

Assistance Disclosure

No AI was used.

Fixes: #7277

Introducing new usagePool named inflightHosts which store the host is still in-flight upstream in reverse proxy Cleanup phase. and when proxyLoopIteration returns done, the inflightHost drain in the usagePool.
Here is scope for improvement because it is draft status now.

@u5surf u5surf marked this pull request as ready for review October 4, 2025 14:25
Comment on lines +844 to +848
di.Upstream.Host.countRequest(-1)
inflightHost := inflightHosts.Load(di.Address)
if inflightHost != nil {
host, _ := inflightHost.(*Host)
host.countRequest(-1)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

di.Upstream.Host and inflightHost.(*Host) could point to the same Host, so countRequest(-1) might be applied twice.

Comment on lines +136 to +142
host := new(Host)
existingHost, loaded := inflightHosts.LoadOrStore(u.String(), host)
if loaded {
host = existingHost.(*Host)
}
_ = host.countRequest(numRemaiRequests)
u.Host = host

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a thought - would it be simpler to just add the old host to inflightHosts rather than creating a new one?

@mholt
Copy link
Member

mholt commented Oct 27, 2025

Wondering if a UsagePool is really the right abstraction for this. UsagePools are useful specifically for managing an allocated value based on reference counting.

If the goal is to just count active requests per upstream, maybe a map of map[string]uint is the way to do it? Sync access to the map, of course. But it might be much simpler...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

/reverse_proxy/upstreams - all in-flight requests

3 participants