-
Notifications
You must be signed in to change notification settings - Fork 45
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
backend: Change default interval for instance stats query #666
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand why this is needed and what it should prevent how.
The added check in the current form will always be true, or?
@pothos I thought about it wrong, I think instead of passing in a default interval, we can calculate the interval from the current time (set by the goroutine to be hourly) to the latest timestamp in the table. This would cover any potential case where the server goes down and the query does not run. What do you think? |
I remember why I wanted 2 hours as default - not all instances may check in during an hour and we might not count them then. The minimum considered should probably we always be 2 hours (or at least 90 minutes). It does not hurt if the calculation is done one time or even multiple times per hour but the interval to look back should still be 2 hours then. I don't think we need to make the interval adaptive because when an instance didn't check in the last 2 hours it is probably deleted. Summary:
|
Hey @pothos. There can be a case when the |
f3edf91
to
c52304c
Compare
I think @pothos is right - i think it's more important to keep a constant interval than it is to try to count instances between to the last run. That's going to give more reliable results. Imagine the server is down (or failed) for a day. With your suggestion we would count a whole bunch of transient instances towards the next run, which would look like a spike. But that's only an artifact of the server being down. So we get more reasonable results by doing the "2 hour lookback every hour" thing Kai proposes. |
Following #663 where we add the background job to periodically populate the instance_stats table, we want to ensure that we generate entries for instances that may not check in hourly but are still active. Thus, we consider a 2-hour default interval for instances checking in, maintaining the hourly cadence of the background job as desired.
ebe4ab3
to
2b0f447
Compare
In case of server being down there will be no instance stats created so we need not worry about it, but there can be a case where the |
From what it sounds like, there would be no corruption, and a dip (i.e. to 0) in the case of a server shutdown could be easily explained and would not have an impact on the rest of the stats. Those instances checked in pre-shutdown may also no longer be active post-shutdown, so it probably would not make sense to write those entries after in that case. |
I'd say that's acceptable. |
LGTM |
Following #663 where we add the background job to periodically populate the
instance_stats
table, we want to ensure that we generate entries for instances that may not check in hourly but are still active. Thus, we consider a 2-hour default interval for instances checking in, maintaining the hourly cadence of the background job as desired.