dgraph-io / ristretto

A high performance memory-bound Go cache
https://dgraph.io/blog/post/introducing-ristretto-high-perf-go-cache/
Apache License 2.0
5.64k stars 374 forks source link

Question - Keys added and Keys evicted graphs are similar?? #165

Closed varun06 closed 4 years ago

varun06 commented 4 years ago

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.

Screen Shot 2020-06-26 at 10 05 49 AM

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

Case size = 10gig

jarifibrahim commented 4 years ago

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 4 years ago

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 4 years ago

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 4 years ago

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 4 years ago

@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 4 years ago

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

Screen Shot 2020-06-29 at 11 34 56 AM

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 -

Screen Shot 2020-06-29 at 11 38 43 AM
jarifibrahim commented 4 years ago

@varun06 Maybe a bigger cache is what you need.

varun06 commented 4 years ago

Yup, going to go to 50gig soon.

minhaj-shakeel commented 4 years ago

Github issues have been deprecated. This issue has been moved to discuss. You can follow the conversation there and also subscribe to updates by changing your notification preferences.

drawing