apscheduler icon indicating copy to clipboard operation
apscheduler copied to clipboard

Shared job stores

Open agronholm opened this issue 8 years ago • 15 comments

The top requested feature for APScheduler is the ability to have multiple schedulers running against the same job store. This requires complex coordination between the schedulers. I can think of at least two good candidates for a synchronization backend:

  • Apache ZooKeeper
  • HashiCorp Consul

Any backend for this needs to be capable of providing at least 1) distributed locks, 2) notifications when the scheduler must wake up. This rules out pretty much all "trivial" backends, like file-based locking.

agronholm avatar Dec 01 '17 21:12 agronholm

This feature would be very interesting. I did not took the time to dig into the code, but when the scheduler is DB backed, a simple lock for reading in the DB should do the trick.

Kimamisa avatar Jan 23 '18 14:01 Kimamisa

No it won't. How would the scheduler know to wake up and adjust its next wakeup time? If it doesn't, it could sleep past the next fire time.

agronholm avatar Jan 23 '18 14:01 agronholm

Therefore a notification (pub/sub) mechanism is also required in addition to locking.

agronholm avatar Jan 23 '18 14:01 agronholm

Hum, my bad, I should have looked more precisely. I thought jobs were checked periodically... like at a fixed period of time.

Kimamisa avatar Jan 23 '18 14:01 Kimamisa

That would either severely affect the accuracy of the schedules (with a high interval) or cause a significant load increase (with a low interval). The reactive approach is the only reasonable solution.

agronholm avatar Jan 23 '18 14:01 agronholm

Agreed. I'll just post here this link in which you discussed it a long time ago, because in my case, I don't need a to update my list of jobs, so the mongolock solution would work. https://groups.google.com/forum/#!topic/apscheduler/Gjc_JQMPePc It might also help people in my case.

Kimamisa avatar Jan 23 '18 15:01 Kimamisa

I could see this working with PostgreSQL (with listen/notify) and MongoDB and probably Redis too, but Zookeeper, etcd and Consul would likely make the best backends for shared job stores because they were explicitly designed for things like this.

agronholm avatar Jan 23 '18 15:01 agronholm

Is there any activities for this task? Or in the nearest future? I would like to be a part of it.

StasEvseev avatar Jan 07 '19 13:01 StasEvseev

You could propose a high level solution. This should minimize the wasted effort in the event that I end up rejecting the proposal. Of course you can also write proof-of-concept code if you like.

agronholm avatar Jan 07 '19 13:01 agronholm

this could be a very useful feature to build a redundant scheduling system

dmitrypol avatar Feb 19 '20 17:02 dmitrypol

I've been writing proof-of-concept code in the last few days. Job store sharing and high availability will be the featureof APScheduler 4 that will stand out the most.

agronholm avatar Feb 19 '20 17:02 agronholm

That is fantastic news. Thank you @agronholm. Sorry to be a pest but any ETA on release date (even RC)?

dmitrypol avatar Feb 19 '20 19:02 dmitrypol

I think I gave someone an ETA last summer but I've way overshot that due to a multitude of factors, the most important of which is my available free time which has to be distributed over my many F/OSS projects. I suggest that you keep watching for commits against master to get a clue about the progress. Sometimes weeks or even months can go by without any progress on a particular project.

agronholm avatar Feb 19 '20 20:02 agronholm

Hi @agronholm, I would also need this feature. I was checking the commits and found it was implemented in commit: https://github.com/agronholm/apscheduler/commit/f4e8c3a0242b082fa1ca6ed5c78094f8de5ba439. When can we expect new release ?

rafzei avatar Jul 11 '21 13:07 rafzei

Somebody asked me around this time last year and I told them it's a few months away. I've since been sidetracked by other projects. My intention is to solve a few critical design problems this months and to implement task accounting (how many instances of a task are running on workers). I too want to get this over with since people ask me about apscheduler on a weekly basis.

I suggest that you subscribe to #465 for progress updates.

agronholm avatar Jul 11 '21 15:07 agronholm

All data stores are shareable as of v4.0.0a1.

agronholm avatar Aug 17 '22 20:08 agronholm