Persisting entity information #609
-
Hi, Doing requests with the same entitiyId always returns the same value. Which is perfectly what i expected. Even after restarting flipt. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Hey @renegat4, great question! You're correct that Flipt doesn't store any info about
So instead, Flipt uses a technique where it hashes the It then creates a slice of 'buckets' along with a sorted slice of distributions. The hashed value from above is then checked to see where it would 'fit' in these buckets. All of the code where this is done is here. So, if distribution A has a 30% rollout, then it would 'take up' buckets 0 - 299 (out of 1k buckets). The hashed value is a 32bit integer, which is then mod'ed (% numBuckets) or (% 1000) so that it is guaranteed to be a number between 0 - 999. All of this combined (using consistent hashing of Hope that helps! |
Beta Was this translation helpful? Give feedback.
Hey @renegat4, great question!
You're correct that Flipt doesn't store any info about
entityID
or which variant an entity matches in the database. This is for two main reasons:entityID
s would likely result in a large amount of data being stored since they are basically infinite as they can be any valueSo instead, Flipt uses a technique where it hashes the
entityID
with theflagKey
using this function which uses the stdlib hash/crc32.ChecksumIEEE function to create the hash.It then creates a slice of 'buckets' along with…