Skip to content

Add Redis pub/sub for horizontal SSE scaling #230

@ogazboiz

Description

@ogazboiz

Join our community: https://t.me/+DOylgFv1jyJlNzM0

Description

SSE broadcasts are in-process only. When the backend runs as multiple instances (e.g., behind a load balancer), a stream event processed by instance A is never broadcast to clients connected to instance B.

What Needs to Happen

  • Install ioredis and configure Redis pub/sub
  • On indexer event, publish to Redis channel stream:{streamId} and user:{address}
  • Each instance subscribes to relevant channels and broadcasts to its local SSE clients
  • Add REDIS_URL to .env.example with a graceful fallback to in-process mode when Redis is absent
  • Document the multi-instance deployment pattern in README

Files

  • backend/src/services/sseService.ts
  • backend/src/lib/redis.ts (create)

Acceptance Criteria

  • Events delivered to clients on any instance
  • Works without Redis (single-instance fallback)
  • Connection pool and retry configured

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave programbackendBackend related tasks

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions