SoCreate / service-fabric-distributed-cache

MIT License
36 stars 19 forks source link

MaxCacheSizeInMegabytes with HasPersistedState = true #17

Open Vikhyat08 opened 4 years ago

Vikhyat08 commented 4 years ago

I am using service fabric distributed cache with a stateful service having HasPersistedState = true. I believe HasPersistedState will allow me to have reliable collections backed by disk. If I set MaxCacheSizeInMegabytes to 1000, does it mean all 1000 MB data is in memory backed by disk. Or does it mean Service fabric reliable collection will manage memory footprint having some objects in memory and rest all in disk.

Also, I see in the example HasPersistedState is false but replicationSize is set to 3. Why would we want replication if we are not backing the data to store there would be no way to recreate state in a node because of no snapshots?

lurock commented 4 years ago

It means Service fabric reliable collection will manage memory footprint having some objects in memory and rest all in disk. As far as the replicationSize that is up to you. You would need to refer to the docs on Reliable collections to see if there is any advantage when not backing up the state.

oargaruna commented 4 years ago

If HasPersistedState = false, and all the data is kept in-memory, how is the cache limit being enforced?

Is it possible for the memory footprint to increase beyond the limit set by MaxCacheSizeInMegabytes?

lurock commented 4 years ago

Is it possible for the memory footprint to increase beyond the limit. It is using that setting as a guide to start to removing the least recently used cached items from the store.

oargaruna commented 4 years ago

Can you add an option to impose the size limit? This will be useful for memory constrained environments.