Batch subscriber updates to reduce noise (#703)

Improve scalability by batching subscriber updates on an interval.
When lots of subscribers join, the server ends up spending 20% CPU
sending each state change to everyone. There's a non-trivial amount of
overhead with each send operation.

For publishers, updates are sent right away.
This commit is contained in:
David Zhao
2022-05-20 22:54:02 -07:00
committed by GitHub
parent 8ef53037eb
commit cdf1724d80
4 changed files with 98 additions and 24 deletions
+3
View File
@@ -328,6 +328,7 @@ func TestSubscriberAsPrimary(t *testing.T) {
type participantOpts struct {
permissions *livekit.ParticipantPermission
protocolVersion types.ProtocolVersion
publisher bool
}
func newParticipantForTestWithOpts(identity livekit.ParticipantIdentity, opts *participantOpts) *ParticipantImpl {
@@ -362,6 +363,8 @@ func newParticipantForTestWithOpts(identity livekit.ParticipantIdentity, opts *p
PLIThrottleConfig: conf.RTC.PLIThrottle,
Grants: grants,
})
p.isPublisher.Store(opts.publisher)
return p
}