Skip to content

perf(event-stream): improve reliability#2266

Open
dargmuesli wants to merge 1 commit into
mainfrom
perf/event-stream/reliability
Open

perf(event-stream): improve reliability#2266
dargmuesli wants to merge 1 commit into
mainfrom
perf/event-stream/reliability

Conversation

@dargmuesli
Copy link
Copy Markdown
Member

@dargmuesli dargmuesli commented Apr 17, 2026

This pull request introduces Kafka event stream processing with dead letter queue handling and adds Redis-based email rate limiting to improve reliability and stability. It also refactors message processing logic for notifications and uploads, and adds new dependencies for Kafka and Redis clients.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves server-side event-stream reliability by introducing retry-with-backoff plus dead-letter-queue (DLQ) handling for Kafka consumers, and adds Redis-backed per-second email rate limiting to reduce spikes and improve stability.

Changes:

  • Refactors Kafka event processing into per-topic handlers with retry + DLQ publishing/consumption.
  • Adds Redis-based rate limiting to sendEmail and introduces a Redis dependency wrapper.
  • Adds a generic retry-with-exponential-backoff utility and formalizes “raw message” handlers for notification/upload events.

Reviewed changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
src/server/plugins/event-stream.ts Adds retry/DLQ flow, splits topic handling, and introduces a dedicated DLQ consumer + producer.
src/server/utils/retry.ts New retryWithBackoff helper used by the Kafka plugin.
src/server/utils/notification.ts Adds processRawNotification to centralize parsing/guard logic for Kafka messages.
src/server/utils/upload.ts Adds processRawUpload to centralize parsing/guard logic for Kafka messages.
src/server/utils/email.ts Adds Redis-based per-second mail rate limiting before sending.
src/server/utils/dependencies/redis.ts Introduces a Redis client wrapper (ioredis).
src/server/utils/dependencies/kafka.ts Extracts Kafka client creation into a shared helper.
src/package.json Adds ioredis dependency.
pnpm-lock.yaml Locks ioredis dependency version.
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/server/utils/dependencies/redis.ts Outdated
Comment thread src/server/plugins/event-stream.ts Outdated
Comment thread src/server/plugins/event-stream.ts Outdated
Comment thread src/server/utils/upload.ts Outdated
Comment thread src/server/plugins/event-stream.ts
Comment thread src/server/utils/notification.ts Outdated
Comment thread src/server/utils/email.ts Outdated
Comment thread src/server/utils/email.ts Outdated
Comment thread src/server/utils/email.ts Outdated
@dargmuesli dargmuesli force-pushed the perf/event-stream/reliability branch 2 times, most recently from b8a76f7 to 229a78a Compare April 20, 2026 22:52
@dargmuesli dargmuesli requested a review from Copilot April 20, 2026 22:53
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to improve backend reliability by hardening Kafka event-stream processing (retries + dead-letter queue) and adding Redis-backed email rate limiting, while refactoring notification/upload message handling into “raw” processors.

Changes:

  • Add Kafka consumer retry/backoff handling and a dead-letter queue flow for failed messages.
  • Introduce Redis-based email rate limiting (per-day + per-second) and update notification emailing to use it.
  • Add new utility/dependency modules (retry helper, Redis/Kafka client factories) and related runtime config/deps.

Reviewed changes

Copilot reviewed 11 out of 12 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
src/shared/utils/constants.ts Rename/add email rate limit constants.
src/server/utils/upload.ts Add processRawUpload wrapper for Kafka message decoding/validation.
src/server/utils/retry.ts Add generic retryWithBackoff helper used by Kafka processing.
src/server/utils/notification.ts Refactor to accept Redis + new rate-limit config; add processRawNotification.
src/server/utils/email.ts Add Redis-based per-second gating and switch to per-day limit naming.
src/server/utils/dependencies/redis.ts Add singleton Redis client accessor.
src/server/utils/dependencies/kafka.ts Add Kafka client factory driven by runtime config.
src/server/plugins/redis.ts Add Nitro plugin to initialize/close Redis connection.
src/server/plugins/event-stream.ts Refactor Kafka plugin: topic handler map, retries, DLQ producer/consumer, Redis injection.
src/package.json Add ioredis.
src/nuxt.config.ts Add runtime config for email rateLimit, Kafka brokers, and Redis URL.
pnpm-lock.yaml Lockfile update for ioredis.
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/server/utils/email.ts Outdated
Comment thread src/server/plugins/redis.ts
Comment thread src/server/utils/dependencies/kafka.ts Outdated
Comment thread src/server/plugins/event-stream.ts Outdated
Comment thread src/server/utils/upload.ts Outdated
Comment thread src/server/utils/notification.ts Outdated
Comment thread src/server/utils/notification.ts Outdated
Comment thread src/server/utils/email.ts Outdated
@dargmuesli dargmuesli force-pushed the perf/event-stream/reliability branch from 229a78a to b43631e Compare April 21, 2026 00:19
@dargmuesli dargmuesli force-pushed the perf/event-stream/reliability branch from b43631e to 5b6fda6 Compare April 21, 2026 00:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants