• Resolved Steve Jones

    (@stevejonesdev)


    I have a function that loops though all posts and parses the posts html. Right now I have a schedule set up to run once per day that calls this function. Would it be more performant to create an individual schedule for each post? Depending on the site this could a lot of schedules. Thanks!

Viewing 7 replies - 1 through 7 (of 7 total)
  • @stevejonesdev You would certainly get better performance if you had an individual scheduled action for each post, mostly in that if there was a failure (like a server timeout) it would retry and pick up where the error occurred. A cron-like scheduled action would probably be your best option.

    You could probably get similar performance to batch process posts (like 10 at a time); finer details are up to you to evaluate and test on your environment(s).

    Hi @stevejonesdev ,

    > ..Depending on the site this could a lot of schedules..

    As you pointed out, the question of whether “One schedule or multiple” is more performant will depend on the volume of posts of the site.

    Thread Starter Steve Jones

    (@stevejonesdev)

    I’m using the scheduler in a plugin so it could be any number of posts that need to be scanned.

    Just so I’m clear on how to set up batch processing for lets say 10 post at a time. I would create a schedule with an array of posts as a parameter that would be passed into my action? Maybe there is a better way to step through 10 posts at a time.

    Is there a performance issue with creating potentially hundreds of schedules?

    @stevejonesdev If you go the batch route, I think using a meta key to identify which posts have been scanned is the best approach. With this approach, you can have only one action scheduled, and that action spawns additional actions until all the posts have been parsed.

    From what I know I don’t see how there’d be a performance issue simply due to the number of actions, if the actions were handled appropriately and server resources were sufficient, but @kosiew is official plugin support so probable has more information than I do.

    Plugin Support dougaitken

    (@dougaitken)

    Automattic Happiness Engineer

    Hi @crstauf @stevejonesdev

    Thanks for the discussion here, I’m looping in @wpmuguru for more technical assistance here.

    Thanks,

    Plugin Contributor Ron Rennick

    (@wpmuguru)

    Just so I’m clear on how to set up batch processing for lets say 10 post at a time. I would create a schedule with an array of posts as a parameter that would be passed into my action?

    Instead of passing an array of ids pass the next ID which can be the last ID processed plus one (eg. last id processed is 123 then pass 124). Default the processing function to ID of 1. You process would look like

    – schedule the first job
    – job retrieves & processes 10 posts matching your criteria plus post ID >= arg ID order by post ID ASC
    – stop if query retrieves no posts
    – schedule next job
    – exit

    Hi,

    We haven’t heard back from you in a while, so I’m going to mark this as resolved – if you have any further questions, you can start a new thread.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘One schedule or Multiple?’ is closed to new replies.