-
Notifications
You must be signed in to change notification settings - Fork 14
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
Improve http.Client usage #1891
Comments
Would callers to the sdk want to be able to configure this? Maybe it could be a configuration option to |
@dmihalcik What configuration were you thinking? For pooling I was just going to use DefaultTransport, which only pools 100 connections. That should be fine for even systems with relatively tight memory limits, while still providing a significant benefit over what we are doing today. Let me know your thoughts, thank you! |
### Proposed Changes This change switches us from maintaining a tls config which we then on-demand initialize an `http.Client` with to instead maintain and reuse an `http.Client` instance. This enables us to utilize the connection pooling which occurs within the `http.Transport` to reduce ssl handshakes and thus reduce latency. In addition this change provides us a central place to configure out `http.Client` (`httputil`). Allowing us to easily set configuration options to reduce the security risks of using an unconfigured `http.Client`. Notably timeouts to reduce DoS risks, and control around following redirects to prevent blind SSRF's. This PR 3/4 addresses #1891. After it's merged a small change will be made in the `service` to fully utilize the API being introduced in the SDK here. ### Checklist - [ ] I have added or updated unit tests - [ ] I have added or updated integration tests (if appropriate) - [ ] I have added or updated documentation ### Testing Instructions
This PR follows #1910 by updating `service` to utilize the new `httputil` helper for constructing a client which wont follow redirects, and has sensible timeouts. The prior auth API was marked as deprecated. There is no remaining use within this repo, so it may be able to be removed. Merging this should fully resolve #1891.
We should improve our usage with
http.Client
. We don't currently reuse http clients, or define them in a consistent way in our Go code. This leads to several potential concerns:I plan to address this by creating a public function for returning a well configured http.Client from the
sdk
. Then utilize this client from within the SDK, platform, and backend broadly. If anyone has feedback on this design let me know in Slack or once I submit the PR.The text was updated successfully, but these errors were encountered: