OpenCue icon indicating copy to clipboard operation
OpenCue copied to clipboard

WIP: Host Report cache

Open DiegoTavares opened this issue 5 years ago • 1 comments

Summarize your change. When the service is under heavy load, HostReports start to take a long time to be processed. The hostReports were organized in a simple queue, which caused old reports that became obsolete to take the place of fresh reports that would give the server the right picture of the status of hosts.

To solve this problem, the following solution was implemented:

  • Use a expireAfterWrite cache to keep only the last report of every host
  • Use a WeakReference to make sure processed reports get cleaned from the cache
  • Change the run command of the ThreadPool to query the cache and then run

With this we keep the order of the queue intact, but make sure every host only gets its last hostReport processed. It the service is not under load and hostReports are being processed in less than 100ms, there shouldn't be more than one report for the same host, given that every host reports every 10s-30s, therefore this change only affects the system when it's under pressure.

DiegoTavares avatar Dec 10 '20 23:12 DiegoTavares

Stand by to merge this, I'm refactoring to simplify the logic.

DiegoTavares avatar Dec 21 '20 18:12 DiegoTavares