Skip to content

Conversation

@thehabes
Copy link
Member

No description provided.

@thehabes thehabes marked this pull request as ready for review October 27, 2025 21:35
@thehabes thehabes requested a review from cubap as a code owner October 27, 2025 21:35
- Wrap cache.set(), cache.invalidate(), cache.clear() to broadcast to all PM2 instances
- Listen for 'process:msg' events to sync cache operations across cluster
- Syncs cache data (set), invalidations, and clears across all instances
- No overhead in non-cluster mode (checks process.send)
- Minimal overhead in cluster mode (~1-5ms per operation)
- Test script updated to handle load-balanced environments
- Add console.log to track cache sync messages being sent/received
- Fix test to use limit=1-100, skip=0-9 for better distribution
- Will help diagnose why PM2 broadcast isn't working
- Removed PM2 IPC synchronization attempt (process.send only communicates with master, not other workers)
- Cleaned up duplicate shebang and documentation
- Documented actual PM2 cluster behavior: each instance maintains independent cache
- Cache hit rates ~25% per instance in 4-worker cluster vs 100% in single instance
- Noted options for production: Redis/Memcached, sticky sessions, or accept tradeoff
@thehabes thehabes marked this pull request as draft October 28, 2025 19:58
@thehabes thehabes closed this Dec 5, 2025
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.

Consider Caching with the RERUM API and/or MongoDB Atlas

2 participants