2 ms·
> Feature flags can be checked dozens of times per request My strategy for resolving this is to fetch the flag value once, but to store it in the request objec
by quesera 2y ago
> Feature flags can be checked dozens of times per request
My strategy for resolving this is to fetch the flag value once, but to store it in the request object, so that a) you never have to take the expensive lookup hit more than once per request, and b) there's no risk of an inconsistent value if the flag is updated mid-request.
- CraigJPerry 2y agoWhat’s the use case for re-checking the same feature flag in a single session? I can see why you need to check multiple different flags in a session and I understand the parent point about looking in SQLite for them (effectively a function call into a library in process address space rather than a call over the network for each flag).
- quesera 2y agoSorry, s/session/request/g; corrected above. One example is a multistep transaction processing request. The feature flag could gate several branch points. A memory-mapped SQLite file is great too, but the strategy I describe above is less code to write, adds no new dependencies, is quicker to implement, avoids the SQLite file distribution/availability issues, and should get you a very similar performance improvement.
- jitl 2y agoWhere is the “session object” stored?
- quesera 2y agoApologies, I meant "request object". Corrected above.