Increase frequency of status updates and longer availability threshold (#628)

* Increase frequency of status updates and longer avail. threshold.

* better fix.

* fix room close test failure due to slow peer connection Close

* Perform avg computation more frequently if data has changed
This commit is contained in:
David Zhao
2022-04-19 22:18:00 -07:00
committed by GitHub
parent 7a60278f64
commit 282e2aed49
6 changed files with 57 additions and 34 deletions
+12 -5
View File
@@ -39,6 +39,8 @@ type RedisRouter struct {
ctx context.Context
isStarted atomic.Bool
statsMu sync.Mutex
// previous stats for computing averages
prevStats *livekit.NodeStats
pubsub *redis.PubSub
cancel func()
@@ -479,13 +481,18 @@ func (r *RedisRouter) handleRTCMessage(rm *livekit.RTCNodeMessage) error {
}
r.statsMu.Lock()
updated, err := prometheus.GetUpdatedNodeStats(r.currentNode.Stats)
if r.prevStats == nil {
r.prevStats = r.currentNode.Stats
}
updated, computedAvg, err := prometheus.GetUpdatedNodeStats(r.currentNode.Stats, r.prevStats)
if err != nil {
logger.Errorw("could not update node stats", err)
} else {
if updated != nil {
r.currentNode.Stats = updated
}
r.statsMu.Unlock()
return err
}
r.currentNode.Stats = updated
if computedAvg {
r.prevStats = updated
}
r.statsMu.Unlock()