Giter VIP home page Giter VIP logo

Comments (7)

timgit avatar timgit commented on July 17, 2024 2

What if we cache the schedules once every 30s and then eval each second? It's a compromise that I think most would accept.

from pg-boss.

timgit avatar timgit commented on July 17, 2024

The scheduling section in the docs explains that minute-level precision is the minimum cron precision. Does this answer your question?

from pg-boss.

marklu avatar marklu commented on July 17, 2024

I asked this question after reading the scheduling section of the docs.

Even though second-level precision is discouraged due to the amount of times the database needs to be hit, does it make sense to allow for an override of the checking precision to allow for second-level precision?

Would you be open to a pull request that makes it possible to override how often the schedule is checked and thus allow for second-level precision use cases?

from pg-boss.

joshualyon avatar joshualyon commented on July 17, 2024

As a preface, we've been looking at pg-boss for queuing / scheduling and this was one of our concerns as well. When I saw this issue, the approach you mentioned is exactly what I was thinking. Query periodically and hold any items which would occur between now and the next query window in memory and execute them at their appropriate time.

I just wasn't intimately familiar with the codebase and if this was reasonable. In other words, I wasn't sure if the system needed to maintain a 'lock' on each job/entry and if there were limits on how long those locks could be held before being ack'ed. From a quick look at the docs, I suppose this is the job moving from createdactive and how long it's allowed to stay in that state before it transitions to expired and it looks like the default is 15 minutes.

from pg-boss.

timgit avatar timgit commented on July 17, 2024

The current implementation uses an internal queue with denouncing hard-coded to 60s. For per-second cron, this would need to be changed to 1s

from pg-boss.

joshualyon avatar joshualyon commented on July 17, 2024

Isn't the internal queue responsible for calling the onCron() function which is grabbing the scheduled items, filtering to schedules that should have run in the last 60 seconds, and sending them to their actual destination queue for work?

If I understand correctly, onCron() currently filters the list of jobs using shouldSendIt() to determine if the schedule is within the time range to send (last 60 seconds) and then 'sends' those tasks.

I was under the impression that you wanted to limit the heavier queries to the database to retrieve the full list of scheduled items, so you wanted to keep the at least 60 second debounce in place... as such, I was thinking something along the lines of changing the way the jobs were enqueued.

In other words, instead of onCron() filtering for schedules which should have already passed and enqueuing those with send(), it could filter to upcoming schedules and then it could use sendAfter() so the enqueued jobs get scheduled with second level precision.

from pg-boss.

timgit avatar timgit commented on July 17, 2024

The debounce I'm mentioning is to ensure 2 pgboss instances running cron monitoring can't create more than 1 job within the cron expression.

from pg-boss.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.