
Leaderless distributed scheduling for Node.js clusters.
Project details
Anarchon brings leaderless cron and interval scheduling to Node.js clusters, allowing for seamless job execution across multiple instances. By leveraging atomic claims in various data stores, it ensures reliability and fault tolerance. Ideal for robust applications requiring distributed job management without the complexity of locks.
Anarchon provides a sophisticated framework for distributed cron and interval scheduling without the need for a centralized leader or distributed locks. This project enables seamless execution of jobs across multiple instances, ensuring that only one instance handles each scheduled task through an atomic claim. The scheduling strategy guarantees reliable job execution, even in the face of instance failures or network issues.
Job Scheduling: Jobs can be scheduled using various intervals, cron expressions, and one-off timings. Instances compute the same run times and execute with some randomness to prevent contention.
Atomic Claims: Each instance tries to claim a job, ensuring that only one runs the task while others act as backups ready to take over in case the primary instance fails.
Lease Mechanism: A lease strategy ensures that in the event of a failure, another instance can take over the job after a specified duration.
import { RedisBackend, Scheduler } from 'anarchon';
const scheduler = new Scheduler({ backend: new RedisBackend({ redis: 'redis://localhost:6379' }) });
scheduler
.every('sync', '10s', async (ctx) => { /* task implementation */ })
.cron('digest', '0 */2 * * *', async (ctx) => { /* task implementation */ });
await scheduler.start();
A demonstration with three instances showcases the behavior of Anarchon:
For complete documentation, including setup guides, examples, and advanced configuration options, visit the official Anarchon documentation.
By adopting Anarchon, developers gain an efficient, leaderless scheduling system that enhances the reliability and maintainability of distributed applications.
Comments
0Start the conversation
Share the first comment.