Question - Keys added and Keys evicted graphs are similar?

Moved from GitHub ristretto/165

Posted by varun06:

Hey Folks,

I am testing Ristretto in QA environment. I am still trying to understand few things. Once thing that I noticed, line for Keys Added and Keys Evicted are super close to each other.

I have a feeling that I am doing something wrong here.

Case size = 10gig

jarifibrahim commented :

Hey @varun06, once the cache reaches the capacity (10 gigs) in this case, every new addition would try to make space for new insertions and so it would cause evictions.
Also, while inserting an item in the cache, you would set the cost param in the cache.Set call. Ensure that cost represents the correct cost of the item. If you set the cost of a single item as 10 GB, ristretto will evict all the old data when this key is inserted.

varun06 commented :

Thanks a lot @jarifibrahim

That make sense. I am going to find out more about our median/99p response times this week. I am still not clear about cache falling all the way down to 0(I hope that’s not a restart…). But is that also normal?

jarifibrahim commented :

I am still not clear about cache falling all the way down to 0(I hope that’s not a restart…)

@varun06 Do you mean you get 0 hits from ristretto?

varun06 commented :

Apologies, I am definitely seeing the hits. Also there was a restart it seems that cleared the cache ofc.

At this point, I am trying to understand why our keys added stats is almost similar to keys evicted stats. Also added a stat to figure our the response size today.

jarifibrahim commented :

@varun06 I could be wrong but I think the eviction would depend on your access pattern. if you’re inserting data that never gets accessed and then new data is inserted, the old data will be evicted. Maybe look at the cache metrics (cache.Metrics) and see how your hits/misses are doing.

varun06 commented :

Yeah, that’s how our current pattern for cache hits is looking like -

BTW, this is just test env, if everything goes well, we are planning to deploy to a significant scale.

This is how our get latency look after moving to ristretto -

jarifibrahim commented :

@varun06 Maybe a bigger cache is what you need.

varun06 commented :

Yup, going to go to 50gig soon.