-
Notifications
You must be signed in to change notification settings - Fork 60
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
Support for connection keepalives and connection pooling? #169
Comments
Hi @jdconley, Sorry for the delay. Here's an example that should work that passes the
When I run this I see something like:
I'm on the west coast so your times will likely look different but you can see that the sum of all the requests is less than the total time taken and the connection was re-used. This seems to be dependant how how you're making requests in that you'll likely need to work the added header into your workflow. |
Hey @jdconley, I'm going to close this out unless you need anything else. The short answer is you can pass the |
@justinpolygon hi,
from what I gathered, your library uses cross-fetch, so this is relevant. thanks |
Yeah, you're right. I didn't notice they closed this. Every request requires a new connection with this library at this time. |
Hey, thanks for the heads up @nitzan-blink. I'll explore this. Sorry, @jdconley I thought this was actually closed as resolved with the |
@justinpolygon I looked through the code and was able to get around this by ignoring the typing on the global options for the rest client and provide my own agent option to fetch, since it looks like client-js just passes the unknown properties of the options object straight through to fetch. Looking through performance traces I no longer see time spent in connection opening per request. @nitzan-blink Snippet for the fix here... Looks like you can pass any fetch option in this way. const client = restClient(this.polygonApiKey, this.apiRootEndpoint, {
agent: function (_parsedURL: URL) {
if (_parsedURL.protocol == 'http:') {
return httpAgent;
} else {
return httpsAgent;
}
},
} as any); // casting to any to pass in our agent config |
Is there a way to turn on connection pooling and keep-alives for the REST API? Does the backend API support this? We are Launchpad users and looking at our logs it seems we are establishing a new tcp connection and TLS negotiation with every request adding around 100ms. This is a request for documentation....
The text was updated successfully, but these errors were encountered: