-
Notifications
You must be signed in to change notification settings - Fork 2
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
Redis data store: Why are per-process keys required for MIN/MAX aggreggations? #1
Comments
Hi! Interesting question!
Just out of curiosity... Are you using this Redis-based store? |
Hi! Thanks for a very quick reply! I hadn't considered incrementing/decrementing gauges. That indeed wouldn't work with my solution. I'm surprised to hear that the Redis store performed so poorly! Instinctively, it felt like the more "natural" choice for a multi-process application. But I suppose I should focus on the officially supported DirectFileStore then :) I'm very new to Prometheus. I was looking into setting up some metrics for a web application at work, using Rails and Sidekiq on a Docker Swarm, and was just looking at the various stores. So I haven't set up anything yet, and unfortunately can't speak for the usefulness of the Redis store. :) Regards, |
I feel this too! So much so, that out of that instinct and the surprise of the result was born a conference talk, because I just couldn't believe it... And yes, given your use cases, I'd recommend sticking to the "official" supported data stores until you have a more specific need. This repo was mostly for documenting experiments, results, and for anyone that might want to try the |
Hi!
I might be missing something, but I don't understand the need to keep individual Redis hash keys per process in order to support MIN and MAX aggregation of metrics.
It seems completely possible to only keep one key for the maximum or minimum reported value in Redis.
For MAX, simply just write the new value
v_new
to keyk
iff:k
has no old valuev_old
OR
v_old < v_new
and the same for MIN, but with a flipped inequality sign.
AFAIK, there is no built-in Redis function to do this atomically in a single command (i.e. without the risk of some other process modifying the value in between read/write), but atomicity can easily be ensured using EVAL with a Lua script.
Here's an example ruby function that does this (extra verbose for readability).
Example program:
Output:
Is there something I haven't considered? :)
Best,
Olof
The text was updated successfully, but these errors were encountered: