Lessons Learned

contact@vinta.com.br

Django prefetch_related makes an extra query to pre-fill the related objects. If you use prefetch_related 3 times in the same queryset Django ORM will hit the database 4 times to fetch all the results.

Did you like?
1

heroku's addons for memcached are not explicitly compatible with Celery as result backends, but you can use them with django-celery-results https://github.com/celery/django-celery-results

We created a custom cache for Celery and used Memcached Cloud. Our settings for this are looking like:

INSTALLED_APPS = [
    # ...
    'django_celery_results',
    # ...
]

CACHES['celery'] = {
    'BACKEND': 'django_bmemcached.memcached.BMemcached',
    'LOCATION': MEMCACHED_SERVERS,
    'OPTIONS': {
        'username': MEMCACHED_USERNAME,
        'password': MEMCACHED_PASSWORD,
    }
}

CELERY_RESULT_BACKEND = 'django-cache'
CELERY_CACHE_BACKEND = 'celery'

Obs.: To use Memcached Cloud on Django you have to follow these instructions

Did you like?
1