fusionauth-netcore-client icon indicating copy to clipboard operation
fusionauth-netcore-client copied to clipboard

Performance Optimization

Open lukevp opened this issue 5 years ago • 2 comments

In .net core, HttpClient is meant to be a singleton with the same lifecycle as an endpoint.

This is the canonical guide for the issues this causes, but it is significant and can make .net core software really unstable as time goes on. It also prevents connection pooling, which means lower performance for users of this library. https://aspnetmonsters.com/2016/08/2016-08-27-httpclientwrong/

It appears like the call chain in FusionAuthClient for all methods is to call buildClient() which calls buildAnonymousClient which creates a new instance of DefaultRESTClient for every request. Is this something you would consider improving on? I'm not super clear on if this library is code generated from another, I would be willing to help with this but not sure the best way to make this change.

lukevp avatar May 26 '20 01:05 lukevp

I've been running into socket exhaustion issues when trying to update large numbers of users, which I assume is caused by this. I've implemented a solution that pools the HttpClient based on the host, which in my case means only 1 will be created. It could be changed to only use a single HttpClient but that would involve changing how the request URI is built and I don't want to open that can of worms.

epbensimpson avatar Feb 15 '22 23:02 epbensimpson