Skip to content
This repository has been archived by the owner on May 13, 2022. It is now read-only.

Add an option to collect statistics data only when there are connected clients #33

Open
KonishchevDmitry opened this issue Mar 14, 2014 · 1 comment

Comments

@KonishchevDmitry
Copy link

On my low loaded server the most of time scout_realtime is in top of CPU consuming processes. I believe it makes sense to add an option to collect the statistics data only when there are connected clients to reduce CPU usage.

@andre
Copy link
Contributor

andre commented Mar 14, 2014

Thanks @KonishchevDmitry. If anyone wants to tackle this:

  1. record a time stamp of the last request to /stats.json (https://github.com/scoutapp/scout_realtime/blob/master/lib/scout_realtime/web_app.rb#L55)
  2. if the last request to /stats.json is older than some threshold (say, 10 seconds), don't run the collectors (or make the collector runs null-ops)
  3. we'd probably want to keep the collectors running for a few minutes after startup, so you still see fully populated charts your first pageview after starting the agent.

One open question is what to do with the historical metrics when the collectors are paused. The collectors use a RingBuffer to store 60 trailing values from each metric (via https://github.com/scoutapp/scout_realtime/blob/master/lib/scout_realtime/lib/aggregator.rb). If you just stop collecting data, the contents of the RingBuffer will still be there when you start again, which will display old data in the charts when you revisit the page.

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

No branches or pull requests

2 participants