-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
👑 feat: Distributed Leader Election with Redis for Multi-instance Coordination #10189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
packages/api/src/cluster/__tests__/LeaderElection.cache_integration.spec.ts
Outdated
Show resolved
Hide resolved
packages/api/src/cluster/__tests__/LeaderElection.cache_integration.spec.ts
Outdated
Show resolved
Hide resolved
988e7eb to
a6d86bc
Compare
a6d86bc to
bf5e36c
Compare
|
@danny-avila would you mind taking a gander on this feature. With this we can not only move forward with Dynamic MCP Servers but this will also allow use to run cro jobs that only the leader node is supposed to handle. This feature works with both Redis and non Redis configurations. It's also cloud-deployment agnostic (whether it's rackbased, AWS, GCP...) and can scale to any number of nodes. |
32e727b to
2705a5a
Compare
|
Will review by the end of the week, thanks |
2705a5a to
77dd61c
Compare
77dd61c to
536ef20
Compare
|
reviewing this today, thanks for your contribution and patience! |
…rdination (danny-avila#10189) * 🔧 refactor: Move GLOBAL_PREFIX_SEPARATOR to cacheConfig for consistency * 👑 feat: Implement distributed leader election using Redis
…rdination (danny-avila#10189) * 🔧 refactor: Move GLOBAL_PREFIX_SEPARATOR to cacheConfig for consistency * 👑 feat: Implement distributed leader election using Redis
…rdination (danny-avila#10189) * 🔧 refactor: Move GLOBAL_PREFIX_SEPARATOR to cacheConfig for consistency * 👑 feat: Implement distributed leader election using Redis
Coming from Dynamic MCP Servers discussion: 2nd bullet point under Implementation.
Summary
This PR implements a distributed leader election system using Redis, enabling LibreChat to coordinate tasks across multiple server instances in a cluster deployment.
Changes
Core Implementation
LeaderElectionclass (packages/api/src/cluster/LeaderElection.ts)SET NXcommandRefactoring
GLOBAL_PREFIX_SEPARATORtocacheConfigfor centralized configurationTesting & CI
test:cache-integration:clusternpm scriptcache/orcluster/directoriesTest File Naming
.cache_integration.spec.tssuffix for consistencyTechnical Details
How it works:
isLeader()to check/claim leadershipUse cases:
Testing
All tests pass with proper cleanup and no hanging processes.
Testing
New tests have been added to CI.
Checklist
Please delete any irrelevant options.