Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

should I turn on metric switch within high concurrency application? #238

Open
lypro09539 opened this issue Jan 30, 2024 · 0 comments
Open

Comments

@lypro09539
Copy link

lypro09539 commented Jan 30, 2024

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)
	}

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant