Skip to content

perf(queue): keep customer replies ahead of receipts and scheduled sends - #1676

Merged
viethung0o0 merged 2 commits into
mainfrom
perf/integration-queue-latency
Nov 9, 2026
Merged

viethung0o0 merged 2 commits into
mainfrom
perf/integration-queue-latency

Conversation

@viethung0o0

@viethung0o0 viethung0o0 commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Bot replies stayed slow at peak because receipts, echoes and scheduled sends shared one FIFO line with customer messages on the integration queue.
  • Read receipts, delivery statuses and channel echoes move to the low queue, so they no longer sit ahead of customer replies.
  • Broadcast and sequence sends now yield to live traffic on every step, not just the first.

Changes

  • Priority: live traffic and running flows keep FIFO order (no priority, so a flow can't stall half-way); broadcast / sequence (5) and missed-comment replay (10) run behind them.
  • Receipts, statuses and echoes (Messenger, Instagram, Zalo, TikTok) go to low. A WhatsApp template status whose Delivered/Failed button leads to another node stays on integration, tracked by a 24h Redis marker written once the message is saved.
  • Bulk low jobs (attachment and avatar mirroring, missed-comment replay) yield to receipts and echoes.
  • contactLastReadAt only moves forward, so out-of-order receipts can't move it back.
  • The integration worker logs integration / chat / low queue depth every minute.
  • docs/scaling-messaging.md: queue design and tuning guide. Default concurrency is unchanged.

Deploy note

  • Deploy the worker before the builder.
  • Roll back the builder before the worker; an older worker drops the new low job types.

Test plan

  • pnpm lint
  • pnpm check-types (builder, worker, worker-config, business, flow-config, 5 channel integrations)
  • Tests: builder, worker, business, worker-config, flow-config, messenger, instagram, instagram-facebook, zalo, tiktok
  • Local fake webhooks with a test flow: keyword → text, text, template; continuations run without priority, a sequence run keeps priority 5 on every step; the wired Delivered status stays on integration and runs its branch; read / failed / text delivered go to low; Zalo echo goes to low
  • Watch queue depth logs after deploy

@github-actions github-actions Bot added the improvement Refactor or performance improvement label Nov 9, 2026
@viethung0o0
viethung0o0 force-pushed the perf/integration-queue-latency branch from cdc9bb6 to 9036a14 Compare November 9, 2026 13:17
@viethung0o0
viethung0o0 marked this pull request as ready for review November 9, 2026 16:19
@viethung0o0
viethung0o0 merged commit d5beadd into main Nov 9, 2026
14 checks passed
hello-jackytruong referenced this pull request in hello-jackytruong/ChatWorkAI Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

improvement Refactor or performance improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants