should I turn on metric switch within high concurrency application?
lypro09539 opened this issue · 0 comments
lypro09539 commented
I import this outstanding lib into my app to use its /store/ristretto/v4, and there will be about 80000 QPS concurrency in our production, so should I use cache.NewMetric to enable metric?
Because I find each Get() will generator a observe operation, on the other hand the codec channel buffer length which is 10000 maybe also cause goroutines suspend, is that right? I finaly plan to lower metric sampling rate through code below, I wonder there is better way to reach it or not?
thank you
ristrettoStoreShelfTidy = ristretto_store.NewRistretto(ristrettoCache)
promMetrics := metrics.NewPrometheus("shelf_tidy_cache", metrics.WithNamespace("local"))
ristrettoStoreShelfTidyWithMetric = cache.NewMetric[any](
promMetrics,
cache.New[any](ristrettoStoreShelfTidy),
)
// ***** some lines skipped
if rand.Intn(100) < 1 { // only one out of a hundred it will use metric instance to lower sampling rate
ristrettoStoreShelfTidyWithMetric.Get(ctx, key)
} else {
ristrettoStoreShelfTidy.Get(ctx, key)
}