01. Event daemons: processing dispatch queues.
When sending notifications or digests to thousands of subscribers, synchronous execution blocks the main application process. We architected a multi-worker event dispatcher in Node.js/NestJS that reads batches from the database and processes dispatches asynchronously using isolated worker threads.
This design prevents latency spikes on user-facing API routes, ensuring that sub-millisecond page edits never suffer from backend process congestion.
02. Webhook verification: cryptographic signs.
Trust is crucial when syncing subscriber actions with third-party providers. Our NestJS webhook endpoints sign outgoing payloads using HMAC-SHA256 signatures, allowing recipient systems to cryptographically verify that the event payload originated from our servers.
By enforcing unique replay-prevention headers and timestamp verification thresholds, we prevent replay attacks and secure internal system events.
03. Local verification: mock dispatcher hooks.
To avoid polluting production mail services during sandbox builds, we created local-first dispatch controllers. Developers can run and inspect email deliveries within the terminal daemon without initiating real mail requests.
This local validation loop mirrors the live provider runtime, allowing local testing of complex retry limits and failover states before deployment.
04. Optimizing throughput: concurrent limits.
By tuning Express middleware thread limits and adjusting database pool limits inside NestJS, the subscriber service achieves a stable throughput of 850 dispatches per second on standard EC2 instances—with complete error logging and automated failure retries.