From bb23a495899195d09716ba4a68fa0026aaaa587a Mon Sep 17 00:00:00 2001 From: Matt Westcott Date: Wed, 10 Sep 2014 19:24:18 +0100 Subject: [PATCH] Add Celery documentation (and additional advice on Redis) to the Performance howto, since it isn't going to be a default part of the project template / VM --- docs/howto/performance.rst | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/docs/howto/performance.rst b/docs/howto/performance.rst index 68c642520..f87e405c0 100644 --- a/docs/howto/performance.rst +++ b/docs/howto/performance.rst @@ -13,7 +13,7 @@ We have tried to minimise external dependencies for a working installation of Wa Cache ----- -We recommend `Redis `_ as a fast, persistent cache. Install Redis through package manager and enable it as a cache backend:: +We recommend `Redis `_ as a fast, persistent cache. Install Redis through your package manager (on Debian or Ubuntu: ``sudo apt-get install redis-server``), add ``django-redis-cache`` to your requirements.txt, and enable it as a cache backend:: CACHES = { 'default': { @@ -25,7 +25,22 @@ We recommend `Redis `_ as a fast, persistent cache. Install Re } } -Without a persistent cache, Wagtail will recreate all compressable assets at each server start, e.g. when any files change under ```./manage.py runserver```. +Without a persistent cache, Wagtail will recreate all compressable assets at each server start, e.g. when any files change under ``./manage.py runserver``. + + +Sending emails in the background using Celery +--------------------------------------------- + +Various actions in the Wagtail admin backend can trigger notification emails - for example, submitting a page for moderation. In Wagtail's default configuration, these are sent as part of the page request/response cycle, which means that web server threads can get tied up for long periods if a large number of emails is being sent. To avoid this, Wagtail can be configured to do this as a background task, using `Celery `_ as a task queue. To install Celery, add ``django-celery`` to your requirements.txt. A sample configuration, using Redis as the queue backend, would look like:: + + import djcelery + + djcelery.setup_loader() + + CELERY_SEND_TASK_ERROR_EMAILS = True + BROKER_URL = 'redis://' + +See the Celery documentation for instructions on running the worker process in development or production. Search