statsig-io / statsig-feedback

Issue Tracker for Statsig. Leave your feedback on anything we do!
5 stars 0 forks source link

Why are checkGate and getConfig asynchronous? #5

Closed twk closed 3 years ago

twk commented 3 years ago

In a past job, unpredictable performance from our feature gating library was an ongoing nightmare. When I see that checkGate and getConfig are asynchronous, it makes me worry that you might be making HTTP calls under the hood (as opposed to loading all the rules ahead of time). Can you tell me what's going on in there?

Thanks!

jkw-statsig commented 3 years ago

Great question @twk! We are indeed loading all the rules at initialization ahead of time and evaluating them without making http calls (you can take a look at our evaluation code here if you are curious). The checkGate and getConfig APIs in our server SDKs are only async because we are trying to make the current SDKs more future proof and able to fetch the values from our server in case in the future we introduce new rule conditions that older version of SDKs do not know how to evaluate.

Hope that helps and let me know if you have more questions or suggestions!

twk commented 3 years ago

That makes sense, thank you!

roim commented 3 years ago

That makes sense, thank you!

@twk If the SDK finds a condition it doesn't yet know how to evaluate, we could return a default value instead of going through a network request. We'll have that as an option eventually, if it's important for you let us know and we can bump its priority.

roim commented 3 years ago

I added an explanation to our server sdk docs. Thanks again for bringing this up