-
Notifications
You must be signed in to change notification settings - Fork 71
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
Replace http util reverese proxy with custom request forwarding #436
base: main
Are you sure you want to change the base?
Conversation
d10ca7a
to
24b3600
Compare
@phillebaba maybe time for a benchmark? |
Yup I am working on it, but things need to be worked on a bit. Currently doing it manually. Also using pprof to explore the call stack. |
@@ -87,6 +86,7 @@ func NewRegistry(ociClient oci.Client, router routing.Router, opts ...Option) *R | |||
r := &Registry{ | |||
ociClient: ociClient, | |||
router: router, | |||
httpClient: &http.Client{}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we initialize it with some sane default?
httpClient := &http.Client{
Transport: &http.Transport{
MaxIdleConns: 20,
MaxIdleConnsPerHost: 20,
},
}
This has been quite helpful for me: https://github.com/XenitAB/go-oidc-middleware/blob/main/.github/workflows/benchmark.yaml |
24b3600
to
2ea1404
Compare
2ea1404
to
548b6b1
Compare
Some testing shows that this does not increase the performance. Either way it is a good change which gives us more control on top of reducing complexity. |
The current implementation with reverse proxy was overly complex. Partially this is due to the retry logic implemented, but also the details of how things are implemented in the package. We really do not need all of the features of reverse proxy as we are not forwarding generic requests that could in theory contain any type of data. Instead the requests forwarded are specific to the OCI distribution spec.
This is the reason for replacing reverse proxy with out own http client that forwards requests.
An additional aspect is that the std lib reverse proxy does not use splice or send file when copying the response body. This solution should in theory improve performance.