Skip to content

Conversation

raju-opti
Copy link
Contributor

@raju-opti raju-opti commented Oct 6, 2025

Summary

The cmab service caches the results of a cmab prediction retrieved from the server and returns it for subsequent calls. This ensures a consistent value is returned for getDecision() within the cache ttl. However, when there is no cached value, if there are concurrent calls to gertDecision() for same userId and ruleId combination, all of these will cause a call to the server and may potentially return different values.

The solution is to run concurrent calls for same userId and ruleId combinations one after another. To achieve this, we put each (userId, ruleId) combination in one of the predefined bucktes by hashing the (userId, ruleId) combination and serialize all calls for that particular hash % (num_buckets).

Test plan

  • added tests

Issues

  • FSSDK-11898

The cmab service caches the results of a cmab prediction retrieve
from the server and returns it for subsequent call. This ensures
a consistent value is returned for getDecision() within the cache ttl.
However, when there is no cached value, if there is concurrent calls
to gertDecision() for same userId and ruleId combination, all of these
will cause a call to the server and may potentially return different
values.

The solution is to run concurrent calls for same userId and ruleId
combinations one after another. To achieve this, we put each (userId, ruleId)
combination in one of the predefined bucktes by hashing the
(userId, ruleId) combination and serialize all calls for that
particular hash % (num_buckets).
@coveralls
Copy link

coveralls commented Oct 6, 2025

Coverage Status

coverage: 78.946% (-0.05%) from 78.991%
when pulling 5777ab3 on raju/cmab_concurrent
into f04de07 on master.

Copy link
Contributor

@junaed-optimizely junaed-optimizely left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great solution! LGTM!

@raju-opti raju-opti merged commit ccd6adb into master Oct 6, 2025
15 of 22 checks passed
@raju-opti raju-opti deleted the raju/cmab_concurrent branch October 6, 2025 18:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants