spegel
spegel copied to clipboard
Replace http util reverese proxy with custom request forwarding
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.
@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.
This has been quite helpful for me: https://github.com/XenitAB/go-oidc-middleware/blob/main/.github/workflows/benchmark.yaml
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.