Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connection reuse in proxy mode #1045

Open
4 of 6 tasks
ecktom opened this issue Dec 23, 2022 · 0 comments
Open
4 of 6 tasks

Connection reuse in proxy mode #1045

ecktom opened this issue Dec 23, 2022 · 0 comments
Labels
bug Something is not working.

Comments

@ecktom
Copy link
Contributor

ecktom commented Dec 23, 2022

Preflight checklist

Describe the bug

When using Oathkeeper in proxy mode and putting some higher RPS on it we noticed that there is something fishy w.r.t. to connection reuse. We saw plenty of new connections getting established, leading to higher load on CoreDNS etc.

On a fast glance, we think it could be related to https://github.com/ory/oathkeeper/blob/master/proxy/proxy.go#L74. Go's DefaultTransport has an insane default setting for idle connections. While it allows up to 100 idle connections, the number is limited per host to 2:

var DefaultTransport RoundTripper = &Transport{
	...
	MaxIdleConns:          100,
	...
}
// DefaultMaxIdleConnsPerHost is the default value of Transport's
// MaxIdleConnsPerHost.
const DefaultMaxIdleConnsPerHost = 2

I would propose using something like

t := http.DefaultTransport.(*http.Transport).Clone()
t.MaxIdleConns = 100
t.MaxIdleConnsPerHost = 100
	
res, err := t.RoundTrip(r)

Reproducing the bug

See Description

Relevant log output

No response

Relevant configuration

No response

Version

0.40.0

On which operating system are you observing this issue?

None

In which environment are you deploying?

None

Additional Context

No response

@ecktom ecktom added the bug Something is not working. label Dec 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is not working.
Projects
None yet
Development

No branches or pull requests

1 participant