Skip to content
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

Usage in clustered environment #45

Closed
gitkeerthi opened this issue Jan 24, 2023 · 6 comments
Closed

Usage in clustered environment #45

gitkeerthi opened this issue Jan 24, 2023 · 6 comments

Comments

@gitkeerthi
Copy link

gitkeerthi commented Jan 24, 2023

How do you use this in a clustered environment where more than one instance of the scheduler might exist? Is there a feature similar to quartz cluster mode (https://flylib.com/books/en/2.65.1/how_clustering_works_in_quartz.html)?

@reugn
Copy link
Owner

reugn commented Feb 1, 2023

@gitkeerthi Clustering is not supported within the library, but a persistent job store can be implemented independently.

@gedw99
Copy link

gedw99 commented Jun 9, 2023

Maybe a simple global system like etcd , kine or nats would be a simple global locking store .

let’s use NATS because it has subscriptions which is handy.

so the 3 events are:

When a job starts it registers with NATS , so no other servers take the job.

on job start , check with NATS and if not in nats, run the job.

On job finish , unregister with nats

—-

you can embed nats servers in your project too which is handy . Nats will automatically do leader election so if a server fails and new leader is automatically chosen .
It also has gracefull upgrades using lamb duck mode. So this means you don’t have to run a “special jobs locking server” but can just include it in your golang project

—-

I don’t know if Quartz has job lease time and retries , but the above can probably work with the above design .

Btw thos already exists and uses nats for job locking as well as other aspects :

https://github.com/choria-io/asyncjobs

it also has a schedular: https://choria-io.github.io/asyncjobs/overview/scheduled-tasks/

in their code it’s used cron golang module.

maybe there is opportunity to use Quarz but not sure yet.

@bingtianyiyan
Copy link

please have planing for support cluster

@reugn
Copy link
Owner

reugn commented Nov 22, 2023

@gitkeerthi, @gedw99, @bingtianyiyan I've opened a pull request (#80) to support custom job queue implementation that can provide persistent storage and state sharing for jobs. Please review, and let me know if this satisfies your requirement.

@joint-song
Copy link

You mean that we can create multiple instances of Scheduler, and these schedulers can have respective Persistent Queue(We can surely set a field in RDBMS table to seperate each queue jobs)? Each scheduler has own timer, event-loop etc. Please correct me if I misunderstand this solution.

@reugn
Copy link
Owner

reugn commented Mar 23, 2024

By implementing a shared persistence layer, you can enable multiple scheduler instances to retrieve and process jobs. This architecture supports high availability (HA) scenarios and facilitates scalability when job processing becomes highly competitive.

@reugn reugn closed this as completed May 16, 2024
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

No branches or pull requests

5 participants