Last active
December 14, 2015 18:09
-
-
Save matagus/5127534 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* If you don’t care about the results of a task, be sure to set the ignore_result option, as storing results wastes time and resources: | |
@celery.task(ignore_result=True) | |
def mytask(...) | |
something() | |
Results can even be disabled globally using the CELERY_IGNORE_RESULT setting. | |
* Or instead of routing it you could rate limit the task instead, so that only 10 tasks of this type can be processed in a minute (10/m): | |
CELERY_ANNOTATIONS = { | |
'tasks.add': {'rate_limit': '10/m'} | |
} | |
If you are using RabbitMQ, Redis or MongoDB as the broker then you can also direct the workers to set a new rate limit for the task at runtime: | |
$ celery control rate_limit tasks.add 10/m | |
worker.example.com: OK | |
new rate limit set successfully | |
* Disabling rate limits altogether is recommended if you don’t have any tasks using them. This is because the rate limit subsystem introduces quite a lot of complexity. | |
CELERY_DISABLE_RATE_LIMITS = True | |
* Workflow: http://docs.celeryproject.org/en/latest/userguide/canvas.html | |
* | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment