perf(messaging): raise recipient page size to 5000 to cut DB round-trips

Streaming a large-topic send paginated subscribers 1000 at a time, so a
500K-recipient topic issued ~500 subscriber-page queries plus their per-page
target resolutions. Raise MESSAGE_RECIPIENTS_PAGE_SIZE to 5000 (APP_LIMIT_COUNT),
cutting topic-path round-trips ~5x with no extra memory pressure (bounded
concurrency still caps in-flight sends). The streaming test fixture now sizes
itself to the page-size constant so it keeps exercising multi-page pagination.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jake BarnbyandClaude Opus 4.8 committed 2026-06-03 13:41:19 +12:00
1 parent 58d7ae9194
commit 2084b21ae3
2 files changed
+3 -4

No files matched your search

+1 -1
View File
@@ -243,7 +243,7 @@ const RULE_STATUS_VERIFIED = 'verified';
const MESSAGE_SEND_TYPE_INTERNAL = 'internal';
const MESSAGE_SEND_TYPE_EXTERNAL = 'external';
// External message fan-out tuning
const MESSAGE_RECIPIENTS_PAGE_SIZE = 1000; // Recipients resolved from the database per page while streaming a send
const MESSAGE_RECIPIENTS_PAGE_SIZE = 5000; // Recipients resolved from the database per page while streaming a send; aligned with APP_LIMIT_COUNT to minimise round-trips on large topics
const MESSAGE_SEND_CONCURRENCY = 10; // Maximum adapter send requests running concurrently within a single send job
const MESSAGE_DELIVERY_ERRORS_LIMIT = 100; // Maximum number of per-recipient delivery errors retained on a message
const MESSAGE_SEND_MAX_RETRIES = 5; // Maximum number of attempts to deliver a batch when the provider throttles or fails transiently
+2 -3
View File
@@ -292,9 +292,8 @@ class MessagingFanoutTest extends TestCase
public function testRecipientsArePaginatedWithoutSubqueryFilter(): void
{
// 4500 subscribers over a 1000-row page is five pages, with a duplicate identifier inside one page to
// exercise per-page deduplication.
$count = 4500;
// Always span several pages regardless of the configured page size, so cursor pagination is exercised.
$count = MESSAGE_RECIPIENTS_PAGE_SIZE * 2 + 500;
$data = $this->topicDataset($count);
$database = new RecordingDatabase($data['subscribers'], $data['targets']);