This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
package activitypub
|
||||
|
||||
import (
|
||||
"math"
|
||||
|
||||
"github.com/owncast/owncast/activitypub/crypto"
|
||||
"github.com/owncast/owncast/activitypub/inbox"
|
||||
"github.com/owncast/owncast/activitypub/outbox"
|
||||
@@ -36,14 +34,32 @@ func Start(datastore *data.Datastore) {
|
||||
}
|
||||
|
||||
func getOutboundWorkerPoolSize() int {
|
||||
// Use a reasonable fixed worker pool size instead of scaling with followers
|
||||
// This prevents excessive resource usage when streamers have many followers
|
||||
const (
|
||||
minWorkers = 10 // Minimum workers for small instances
|
||||
maxWorkers = 50 // Maximum workers to prevent resource exhaustion
|
||||
defaultWorkers = 20 // Default for most instances
|
||||
)
|
||||
|
||||
var followerCount int64
|
||||
fc, err := persistence.GetFollowerCount()
|
||||
if err != nil {
|
||||
log.Errorln("Unable to get follower count", err)
|
||||
fc = 50 // Arbitrary fallback value.
|
||||
return defaultWorkers
|
||||
}
|
||||
followerCount = int64(math.Max(float64(fc), 50))
|
||||
return int(followerCount * 5)
|
||||
followerCount = fc
|
||||
|
||||
// Scale more conservatively: start with base workers, add 1 worker per 100 followers
|
||||
// This gives a much more reasonable scaling than the previous followerCount * 5
|
||||
workers := minWorkers + int(followerCount/100)
|
||||
|
||||
if workers > maxWorkers {
|
||||
workers = maxWorkers
|
||||
}
|
||||
|
||||
log.Infof("Initializing ActivityPub outbound worker pool with %d workers for %d followers", workers, followerCount)
|
||||
return workers
|
||||
}
|
||||
|
||||
// SendLive will send a "Go Live" message to followers.
|
||||
|
||||
Reference in New Issue
Block a user