Document memory store eviction policy

As a Roblox developer, I would like to have more trust in memory stores by knowing their eviction policy, AKA roughly what happens when I go over the memory limit.

I am currently using memory stores in order to prevent throttling on data stores. My memory stores provide a temporary value that is written back to data stores regularly. This was necessary in order to scale our game to 30k+ concurrent. The system operates under the observation that memory stores are mostly resilient–if they were to wipe the data, the game would still work fine, but some important user actions may be a bit buggier until memory stores get updated with the new values in the data store. This works fine, but is not something that I can afford to let happen frequently.

Because of this, I have avoided using memory stores for anything else. I know about the memory store dashboard, but it’s still possible that any update I might do would blow it up, and I either may not be around to fix it, or it is not trivial to fix, or even turn off.

Basically, my concern is this: if I were to use memory stores for things that aren’t as critical as my data store cache, and I eventually hit the limit, how sure can I be that my data store cache is not going to be repeatedly punted for data I don’t care about?

Redis documents this key eviction process, which is configurable. For example, this eviction process might be random, or it might be something more useful like least-recently-used (which would be my preference, if I could choose). For example, I would feel a lot more free if I knew memory stores cleared LRU, since it would mean a terrible blow up wouldn’t at least affect critical stability.

14 Likes

MemoryStores on Roblox have an eviction policy based on expiration time. This cache policy is based off of TTL (Time to Live). Items are evicted after they expire, and memory quota is freed up for new entries. When you hit the memory limit, all subsequent write requests will fail until items expire or are deleted, and memory is freed up to make room for the new data.

Note: We only evict keys that have expired. When memory limit is reached, we prevent adding more data, but won’t delete any existing keys until they either reach their expiration time or are deleted by you using the RemoveAsync API.

8 Likes

Yeouch, this seems like a pretty big limitation–our local Redis hits our cache limit constantly as part of expected behavior. I will look into making a feature request to see if that can be improved.

Thanks for the useful information, though! Do you think this can be added to the documentation, or is it already there and I missed it? I don’t recall seeing text saying new entries would error at the limit.

1 Like

The API Docs mention that items are removed upon expiration (example - MemoryStoreSortedMap | Documentation - Roblox Creator Hub) but that’s about it. I’ll update the docs to explicitly call this behavior out :slight_smile:

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.