diff --git a/docs/docs/config/notification.md b/docs/docs/config/notification.md index 9033deb8a..729fc3762 100644 --- a/docs/docs/config/notification.md +++ b/docs/docs/config/notification.md @@ -59,31 +59,20 @@ The config items in the _value_ field are ## Broadcast Push Notification Task Concurrency -To achieve horizontal scaling, when a broadcast push notification request, hereby known as original request, is received, _NotifyBC_ divides subscribers into chunks and generates a HTTP sub-request for each chunk. The original request supervises the execution of sub-requests. The chunk size is defined by config _broadcastSubscriberChunkSize_. All subscribers in a sub-request chunk are processed concurrently when the sub-requests are submitted. +To achieve horizontal scaling, when a broadcast push notification request is received, _NotifyBC_ divides subscribers into chunks and submits a BullMQ job for each chunk. The chunk size is defined by config _broadcastSubscriberChunkSize_. All subscribers in a sub-request chunk are processed concurrently when the sub-requests are submitted. -The original request submits sub-requests back to (preferably load-balanced) _NotifyBC_ server cluster for processing. Sub-request submission is throttled by config _broadcastSubRequestBatchSize_. _broadcastSubRequestBatchSize_ defines the upper limit of the number of Sub-requests that can be processed at any given time. - -As an example, assuming the total number of subscribers for a notification is 1,000,000, _broadcastSubscriberChunkSize_ is 1,000 and _broadcastSubRequestBatchSize_ is 10, _NotifyBC_ will divide the 1M subscribers into 1,000 chunks and generates 1,000 sub-requests, one for each chunk. The 1,000 sub-requests will be submitted back to _NotifyBC_ cluster to be processed. The original request will ensure at most 10 sub-requests are submitted and being processed at any given time. In fact, the only time concurrency is less than 10 is near the end of the task when remaining sub-requests is less than 10. When a sub-request is received by _NotifyBC_ cluster, all 1,000 subscribers are processed concurrently. Suppose each sub-request (i.e. 1,000 subscribers) takes 1 minute to process on average, then the total time to dispatch notifications to 1M subscribers takes 1,000/10 = 100min, or 1hr40min. - -The default value for _broadcastSubscriberChunkSize_ and _broadcastSubRequestBatchSize_ are defined in _/src/config.ts_ +The default value for _broadcastSubscriberChunkSize_ is defined in _/src/config.ts_ ```ts module.exports = { notification: { broadcastSubscriberChunkSize: 1000, - broadcastSubRequestBatchSize: 10, }, }; ``` To customize, create the config with updated value in file _/src/config.local.js_. -If total number of subscribers is less than _broadcastSubscriberChunkSize_, then no sub-requests are spawned. Instead, the main request dispatches all notifications. - -::: tip How to determine the optimal value for broadcastSubscriberChunkSize and broadcastSubRequestBatchSize? -broadcastSubscriberChunkSize is determined by the concurrency capability of the downstream message handlers such as SMTP server or SMS service provider. broadcastSubRequestBatchSize is determined by the size of NotifyBC cluster. As a rule of thumb, set broadcastSubRequestBatchSize equal to the number of non-primary nodes in NotifyBC cluster. -::: - ## Broadcast Push Notification Custom Filter Functions ::: warning Advanced Topic diff --git a/docs/docs/miscellaneous/upgrade.md b/docs/docs/miscellaneous/upgrade.md index ddb6fc25b..1377663e0 100644 --- a/docs/docs/miscellaneous/upgrade.md +++ b/docs/docs/miscellaneous/upgrade.md @@ -69,7 +69,9 @@ v6 introduced following backward incompatible changes 2. config `minTime` in `email.throttle` and `sms.Throttle` is replaced with `max` and `duration`. Effectively _minTime=duration/max_. By default `max` is 4 and `duration` is 1000, equivalent to default `minTime` of 250. -3. Terms for [node roles](../config/nodeRoles.md) have changed. If you defined environment variable _NOTIFYBC_NODE_ROLE_ with value _master_, remove the environment variable. If _NOTIFYBC_NODE_ROLE_ has value _slave_, change it to _secondary_. If you deployed NotifyBC using Helm, this change is taken care of. +3. Terms for [node roles](../config/nodeRoles.md) have changed. If you defined environment variable _NOTIFYBC_NODE_ROLE_ with value other than _slave_, remove the environment variable; otherwise change it to _secondary_. If you deployed NotifyBC using Helm, this change is taken care of. + +4. config `notification.broadcastSubRequestBatchSize` is deprecated. If you defined it in _/src/config.local.js_, remove it. ## v4 to v5 diff --git a/src/config.ts b/src/config.ts index 91013c16f..6c6832954 100644 --- a/src/config.ts +++ b/src/config.ts @@ -136,7 +136,6 @@ const config: Record = { }, notification: { broadcastSubscriberChunkSize: 1000, - broadcastSubRequestBatchSize: 10, guaranteedBroadcastPushDispatchProcessing: true, logSkippedBroadcastPushDispatches: false, }, diff --git a/test/notification.e2e-spec.ts b/test/notification.e2e-spec.ts index ef2a6aea6..e97ab9fc8 100644 --- a/test/notification.e2e-spec.ts +++ b/test/notification.e2e-spec.ts @@ -739,7 +739,6 @@ describe('POST /notifications', () => { const origNotificationConfig = appConfig.notification; const newNotificationConfig = merge({}, origNotificationConfig, { broadcastSubscriberChunkSize: 1, - broadcastSubRequestBatchSize: 10, }); appConfig.notification = newNotificationConfig; const res = await client @@ -779,7 +778,6 @@ describe('POST /notifications', () => { const origNotificationConfig = appConfig.notification; const newNotificationConfig = merge({}, origNotificationConfig, { broadcastSubscriberChunkSize: 1, - broadcastSubRequestBatchSize: 10, }); appConfig.notification = newNotificationConfig; @@ -864,7 +862,6 @@ describe('POST /notifications', () => { const origNotificationConfig = appConfig.notification; const newNotificationConfig = merge({}, origNotificationConfig, { broadcastSubscriberChunkSize: 1, - broadcastSubRequestBatchSize: 10, }); appConfig.notification = newNotificationConfig; @@ -915,7 +912,6 @@ describe('POST /notifications', () => { const origNotificationConfig = appConfig.notification; const newNotificationConfig = merge({}, origNotificationConfig, { broadcastSubscriberChunkSize: 1, - broadcastSubRequestBatchSize: 10, }); appConfig.notification = newNotificationConfig; @@ -961,7 +957,6 @@ describe('POST /notifications', () => { const origNotificationConfig = appConfig.notification; const newNotificationConfig = merge({}, origNotificationConfig, { broadcastSubscriberChunkSize: 1, - broadcastSubRequestBatchSize: 10, }); appConfig.notification = newNotificationConfig; @@ -1094,7 +1089,6 @@ describe('POST /notifications', () => { const origNotificationConfig = appConfig.notification; const newNotificationConfig = merge({}, origNotificationConfig, { broadcastSubscriberChunkSize: 1, - broadcastSubRequestBatchSize: 10, logSkippedBroadcastPushDispatches: true, }); appConfig.notification = newNotificationConfig; @@ -1358,7 +1352,6 @@ describe('POST /notifications', () => { const origNotificationConfig = appConfig.notification; const newNotificationConfig = merge({}, origNotificationConfig, { broadcastSubscriberChunkSize: 1, - broadcastSubRequestBatchSize: 2, guaranteedBroadcastPushDispatchProcessing: false, }); appConfig.notification = newNotificationConfig;