From efb9105d6c0a35fae32c91c20172e344470cee6f Mon Sep 17 00:00:00 2001 From: Anton Georgiev Date: Thu, 10 Oct 2024 16:23:53 -0400 Subject: [PATCH] fix: Space out approval of guests to better handle larger groups Space out the group handling of guest accept all. Handle the groups in batches of up to three. Dispatch a new batch approval every 500ms (configurable) --- .../ui/components/waiting-users/service.js | 21 ++++++++++++++++++- .../private/config/settings.yml | 1 + 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/bigbluebutton-html5/imports/ui/components/waiting-users/service.js b/bigbluebutton-html5/imports/ui/components/waiting-users/service.js index ed3d8d519e62..15ab946f4bc0 100644 --- a/bigbluebutton-html5/imports/ui/components/waiting-users/service.js +++ b/bigbluebutton-html5/imports/ui/components/waiting-users/service.js @@ -3,7 +3,26 @@ import Auth from '/imports/ui/services/auth'; import GuestUsers from '/imports/api/guest-users'; import { makeCall } from '/imports/ui/services/api'; -const guestUsersCall = (guestsArray, status) => makeCall('allowPendingUsers', guestsArray, status); +const sizeOfBatches = 3; // commonly deployments have 3-4 or more instances of bbb-html5-frontend +const delayForApprovalOfGuests = Meteor.settings.public.app.delayForApprovalOfGuests || 500; + +const breakIntoSmallerGroups = (array) => { + return array + .map((_, index) => { + return index % sizeOfBatches === 0 ? array.slice(index, index + sizeOfBatches) : null; + }) + .filter(group => group) // remove null values + .map(group => group.filter(item => item !== undefined)); // remove undefined items +}; + +async function guestUsersCall(guestsArray, status) { + // Processing large arrays (20+ guests) puts a lot of stress on frontends + // Here we split the approved guests into batches and space out the batch processing + for (const batch of breakIntoSmallerGroups(guestsArray)) { + makeCall('allowPendingUsers', batch, status); + await new Promise(resolve => setTimeout(resolve, delayForApprovalOfGuests)); + }; +} const changeGuestPolicy = (policyRule) => makeCall('changeGuestPolicy', policyRule); diff --git a/bigbluebutton-html5/private/config/settings.yml b/bigbluebutton-html5/private/config/settings.yml index 77fc3cb41c3b..4d68699ec054 100755 --- a/bigbluebutton-html5/private/config/settings.yml +++ b/bigbluebutton-html5/private/config/settings.yml @@ -66,6 +66,7 @@ public: dynamicGuestPolicy: true enableGuestLobbyMessage: true guestPolicyExtraAllowOptions: false + delayForApprovalOfGuests: 500 alwaysShowWaitingRoomUI: true enableLimitOfViewersInWebcam: false enableMultipleCameras: true