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

How to run CELERY_BEAT_SCHEDULE tasks at different intervals per tenant? #129

Open
royroyee opened this issue Nov 7, 2024 · 5 comments
Open

Comments

@royroyee
Copy link

royroyee commented Nov 7, 2024

Is there a way to stagger CELERY_BEAT_SCHEDULE tasks so that they run at different times per tenant, instead of all tenants executing tasks simultaneously?

When tasks run at the same time across tenants, resource load increases significantly as the tenant count grows. Looking for a straightforward solution to vary task execution times per tenant without complex configurations or major structural changes.

Any guidance or examples on achieving this would be greatly appreciated

@maciej-gol
Copy link
Owner

Unfortunately, I'm not aware of any simple configuration for this :( I could look into this when I'm done implementing the DB scheduler for the tenants. What you are basically looking at is to add a jitter to every scheduler entry.

@aayush-kosh
Copy link

@maciej-gol How's the DB Scheduler for tenants coming along? When do you think we'll be able to merge it?

@maciej-gol
Copy link
Owner

maciej-gol commented Jan 18, 2025

@aayush-kosh do you have any suggestion on how to add jitter to a schedule? My best solution to this is on the user side - to add a random jitter/sleep to your tasks. Otherwise, it is completely not obvious how to offset a periodic task that uses a cron or interval schedule without being extremely confusing to users that the task has actually launched on a different time than specified.

@aayush-kosh
Copy link

Hi @maciej-gol

We managed to get this working. Let me know if you need help with something.

@maciej-gol
Copy link
Owner

maciej-gol commented Jan 29, 2025 via email

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

No branches or pull requests

3 participants