-
Notifications
You must be signed in to change notification settings - Fork 46
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
Performance issues if checking for schedules during every page load #117
Comments
Could we leave the option in the Potentially flaky and not referencing the real source of truth... |
Maybe set an autoloaded option for each scheduled event and check for that before hitting the cavalcade jobs table. Could be keyed on hook and args - issue is the timestamp argument. Maybe bypass option check if timestamp isn't null? |
Was looking into this for a little bit (distractions). So without Cavalcade, WordPress gets the crons from an option within |
The option is completely bypassed currently, I'm not sure I follow the benefit or process of updating the option after the cron event completes? Can you elaborate a bit more? |
When |
The jobs table gets absolutely massive as each run is a new row. Could perhaps do so with a where clause for |
Ah yeah in that case it would need a clause to only fetch future events. The |
Not sure if I addressed elsewhere, but: Cavalcade's design does intentionally query the database for this data rather than using the object cache (valuing freshness over performance), and database queries are not a problem per se, so we need to make sure any solution is worth the cost. I am assuming from this issue that we've directly identified it as an actual performance bottleneck, but I don't recall seeing the discussion anywhere. Querying for all pending jobs (potentially deferred to the first We may only want to do that for recurring jobs rather than all jobs, where
That's an assumption that may not hold; Cavalcade is designed to be able to scale beyond WP's limits, so we wouldn't want to assume the array would still be small. It's not likely to be at the too-big-for-PHP-memory size, but it could be at the too-big-for-one-query size. |
Looks like this was a performance regression ultimately from when we switched to the preflight filters in https://github.com/humanmade/Cavalcade/pull/91/files; previously, we populated the full array once per page load, and the non-persistent cache was then used for follow-ups. Restoring that functionality would likely fix this issue. |
Ah nice. Not totally sure how to go about that with the |
I don't think this plugin is the right place for it but I've written up an alternative approach to avoid the problem described here on frontend requests that we could add to Altis Cloud, and that others could just implement if they wish: Closing this out as the current setup is the best on balance between efficiency and scalability. |
It's a common pattern in WP to check for a scheduled job and add it if it doesn't exist e.g.
Typically the list of cron tasks is stored in the options table which is autoloaded and the impact is pretty minimal in terms of performance to do this check on every invocation of WP.
When using Cavalcade we're not able to rely on any persistent object caching for the database queries so there are additional uncached reads on every page load for every event being checked - this is also on a significantly larger db table than just the value from
wp_options
.ideally we can solve this performance issue to avoid making multiple db queries for this common pattern.
The text was updated successfully, but these errors were encountered: