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

fix(recurring-task): reduce update load on task_processor_recurringtask table (WIP) #23

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

matthewelwell
Copy link
Contributor

@matthewelwell matthewelwell commented Feb 21, 2025

This is a WIP / PoC for a hypothesis that we are seeing a high number of updates on the task_processor_recurringtask table due to the fact that an update_or_create is called every time that a module is reloaded that includes a function decorated with @register_recurring_task().

The general approach is to only update the recurring tasks when the processor starts instead. There's a chance that we could optimise this further and only do it on a deployment, but this should at least reduce the load significantly in environments that are running a lot of instances of the Flagsmith application which may also be getting terminated / instantiated regularly.

Copy link
Contributor Author

@matthewelwell matthewelwell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One minor comment, but overall I'm happy with the additions from @khvn26 .

task_identifier=task_identifier,
task_function=callable_,
)
registered_tasks[task_identifier] = registered_task

logger.debug(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can probably get rid of these log statements. They're just noise, and the statement in initialise should log out all of the registered tasks on processor startup which is the desired behaviour, right?

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

Successfully merging this pull request may close these issues.

2 participants