-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Description
Problem
Currently, KickTalk creates individual connections for each chatroom, leading to poor performance with multiple chatrooms:
- 21 separate KickPusher WebSocket connections (one per chatroom)
- 21 separate 7TV WebSocket connections (one per chatroom)
- 42 sequential emote API calls (21 × 2 services)
- ~30 second startup time with 21 chatrooms
Current Architecture Issues
- Each chatroom creates its own
KickPusherinstance connecting towss://ws-us2.pusher.com - Each chatroom creates its own
StvWebSocketinstance connecting towss://events.7tv.io/v3 - All connections initialize simultaneously without throttling
- No connection sharing or multiplexing
Proposed Solution
Implement connection pooling using Pusher's built-in multiplexing capabilities:
1. Shared KickPusher Connection
- Current: 21 separate WebSocket connections
- Optimized: 1 shared connection with 21 channel subscriptions
- Use
pusher.subscribe()for multiple channels on single connection
2. Shared 7TV Connection
- Current: 21 separate WebSocket connections
- Optimized: 1 shared connection with event multiplexing
3. Optimized Emote Fetching
- Batch emote requests where possible
- Cache global emotes (same across all channels)
- Implement request throttling
4. Staggered Connection Initialization
- Initialize connections in batches (3-5 per second)
- Prioritize active/favorite channels first
Expected Performance Impact
- Startup time: 30 seconds → 5-10 seconds
- WebSocket connections: 42 → 2
- API calls: 42 → ~21 (with caching)
- Resource usage: Significantly reduced
Implementation Plan
- Create
SharedKickPusherclass for connection pooling - Create
SharedStvWebSocketclass for 7TV multiplexing - Implement batch emote fetching with caching
- Add staggered connection initialization
- Update
ChatProvider.jsxto use shared connections
Files to Modify
src/renderer/src/providers/ChatProvider.jsx- Main connection logicutils/services/kick/kickPusher.js- Pusher connection poolingutils/services/seventv/stvWebsocket.js- 7TV connection poolingutils/services/seventv/stvAPI.js- Emote cachingutils/services/kick/kickAPI.js- Emote batching
This optimization will significantly improve the user experience for users with multiple chatrooms open.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels