HTTP connection pooling
klaemo opened this issue · 2 comments
Hey there,
methods like batchCheck
and listRelations
can potentially issue a lot of individual requests. We noticed some rather severe performance issues which we narrowed down to each of those requests doing a new DNS lookup and TCP connection setup.
Once we enabled connection re-use/pooling/keep alive (whatever you want to call it) we saw big improvements.
http.globalAgent = new http.Agent({ keepAlive: true });
https.globalAgent = new https.Agent({ keepAlive: true });
I think this should either be the default for the SDK's axios instance, a parameter for the OpenFgaClient
or the very least mentioned in the docs.
What do you think?
Thanks for the feedback @klaemo!
Please feel free to submit a PR, both in the documentation and setting it as default in the code would be accepted.
Here is the relevant part of the code that instantiates axios if not provided: https://github.com/openfga/js-sdk/blob/main/base.ts#LL43C67-L43C67
Side-note: At some point we'd like to replace axios and move to a framework that allows http2/3 (see: #18), would love your feedback on that then!