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

RFC: Use Redis as celery broker in dev environment #213

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions django-resonant-settings/resonant_settings/celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,14 @@

# CloudAMQP-suggested settings
# https://www.cloudamqp.com/docs/celery.html

Comment on lines 51 to +53
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# CloudAMQP-suggested settings
# https://www.cloudamqp.com/docs/celery.html
# CloudAMQP-suggested settings
# https://www.cloudamqp.com/docs/celery.html

Should this be removed?

# If using Heroku Redis addon, consult the connection limits for your tier to see if it's safe
# to raise this: https://elements.heroku.com/addons/heroku-redis
# Keep in mind that celery workers may not be the only use of Redis in a deployment.
CELERY_BROKER_POOL_LIMIT = 1
CELERY_BROKER_HEARTBEAT = None
CELERY_BROKER_CONNECTION_TIMEOUT = 30
Comment on lines 57 to 59
Copy link
Contributor

Choose a reason for hiding this comment

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

Are all of these values still the appropriate defaults?

If they need to be set per-deployment, these should be moved out of the resonant_settings shared package and into the cookiecutter files.

# The following settings are only used with the AMQP transport.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# The following settings are only used with the AMQP transport.

If we're moving to Redis, we should remove anything AMQP-specific.

CELERY_EVENT_QUEUE_EXPIRES = 60

# Note, CELERY_WORKER settings could be different on each running worker.
Expand Down
2 changes: 1 addition & 1 deletion {{ cookiecutter.project_slug }}/dev/.env.docker-compose
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
DJANGO_SETTINGS_MODULE={{ cookiecutter.pkg_name }}.settings.development
DJANGO_DATABASE_URL=postgres://postgres:postgres@postgres:5432/django
DJANGO_CELERY_BROKER_URL=amqp://rabbitmq:5672/
DJANGO_CELERY_BROKER_URL=redis://redis:6379/0
DJANGO_MINIO_STORAGE_URL=http://minioAccessKey:minioSecretKey@minio:9000/django-storage
DJANGO_MINIO_STORAGE_MEDIA_URL=http://localhost:9000/django-storage
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
DJANGO_SETTINGS_MODULE={{ cookiecutter.pkg_name }}.settings.development
DJANGO_DATABASE_URL=postgres://postgres:postgres@localhost:5432/django
DJANGO_CELERY_BROKER_URL=amqp://localhost:5672/
DJANGO_CELERY_BROKER_URL=redis://localhost:6379/0
DJANGO_MINIO_STORAGE_URL=http://minioAccessKey:minioSecretKey@localhost:9000/django-storage
4 changes: 2 additions & 2 deletions {{ cookiecutter.project_slug }}/docker-compose.override.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ services:
- 8000:8000
depends_on:
- postgres
- rabbitmq
- redis
- minio

celery:
Expand All @@ -34,5 +34,5 @@ services:
- .:/opt/django-project
depends_on:
- postgres
- rabbitmq
- redis
- minio
13 changes: 6 additions & 7 deletions {{ cookiecutter.project_slug }}/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@ services:
volumes:
- postgres:/var/lib/postgresql/data

rabbitmq:
image: rabbitmq:management-alpine
ports:
- 5672:5672
- 15672:15672
redis:
image: redis:latest
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should use the Alpine image.

volumes:
- rabbitmq:/var/lib/rabbitmq
- redis-data:/redis/data
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this path correct? The Docker image shows that VOLUME is at /data.

ports:
Copy link
Contributor

Choose a reason for hiding this comment

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

Put this in consistent ordering as the things in this file: ports before volumes.

- 6379:6379

minio:
image: minio/minio:latest
Expand All @@ -35,4 +34,4 @@ services:
volumes:
postgres:
minio:
rabbitmq:
redis-data:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
redis-data:
redis-data:

Use a name consistent with the others.

2 changes: 1 addition & 1 deletion {{ cookiecutter.project_slug }}/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ version = "0.0.0"
requires-python = ">=3.13"
license = { text = "Apache 2.0" }
dependencies = [
"celery",
"celery[redis]",
"django[argon2]",
"django-allauth",
"django-auth-style",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Redefine these before importing the rest of the settings
os.environ['DJANGO_DATABASE_URL'] = os.environ['DATABASE_URL']
os.environ['DJANGO_CELERY_BROKER_URL'] = os.environ['CLOUDAMQP_URL']
os.environ['DJANGO_CELERY_BROKER_URL'] = os.environ['REDIS_URL']
# Provided by https://github.com/ianpurvis/heroku-buildpack-version
os.environ['DJANGO_SENTRY_RELEASE'] = os.environ['SOURCE_VERSION']

Expand Down