From f2b488932dfb363da2367a8b1a7967f34801952e Mon Sep 17 00:00:00 2001 From: Agniva De Sarker Date: Sat, 13 Jan 2024 08:56:16 +0530 Subject: [PATCH] MM-56355: Use same number of hubs as CPUs (#25798) We randomly used double the number of hubs. A proper test indicates that using the same number of hubs as CPUs gives better performance. https://mattermost.atlassian.net/browse/MM-56355 ```release-note NONE ``` --- server/channels/app/platform/web_hub.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/server/channels/app/platform/web_hub.go b/server/channels/app/platform/web_hub.go index 25f85b643b..0d927d005a 100644 --- a/server/channels/app/platform/web_hub.go +++ b/server/channels/app/platform/web_hub.go @@ -92,8 +92,10 @@ func newWebHub(ps *PlatformService) *Hub { // hubStart starts all the hubs. func (ps *PlatformService) hubStart(broadcastHooks map[string]BroadcastHook) { - // Total number of hubs is twice the number of CPUs. - numberOfHubs := runtime.NumCPU() * 2 + // After running some tests, we found using the same number of hubs + // as CPUs to be the ideal in terms of performance. + // https://github.com/mattermost/mattermost/pull/25798#issuecomment-1889386454 + numberOfHubs := runtime.NumCPU() ps.logger.Info("Starting websocket hubs", mlog.Int("number_of_hubs", numberOfHubs)) hubs := make([]*Hub, numberOfHubs)