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

Add environment setting for Celery concurrency #531

Merged
merged 2 commits into from
Sep 27, 2021
Merged
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
8 changes: 4 additions & 4 deletions dandiapi/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ def before_binding(configuration: Type[ComposedConfiguration]):
'DEFAULT_AUTO_SCHEMA_CLASS': 'dandiapi.swagger.DANDISwaggerAutoSchema',
}

# Some tasks working with lots of data need lots of memory, so we need to artificially lower
# the number of concurrent tasks (default is 8) to keep memory usage down.
CELERY_WORKER_CONCURRENCY = values.IntegerValue(environ=True, default=8)


class DevelopmentConfiguration(DandiMixin, DevelopmentBaseConfiguration):
# This makes pydantic model schema allow URLs with localhost in them.
Expand Down Expand Up @@ -106,7 +110,3 @@ class HerokuProductionConfiguration(DandiMixin, HerokuProductionBaseConfiguratio
# the API server is running in (production/local or staging).
class HerokuStagingConfiguration(HerokuProductionConfiguration):
OAUTH2_PROVIDER_APPLICATION_MODEL = 'api.StagingApplication'

# We are using cheaper Heroku dynos for staging, so we need to artificially lower the number
# of concurrent tasks (default is 8) to keep memory usage down.
CELERY_WORKER_CONCURRENCY = 2
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
include_package_data=True,
install_requires=[
'celery',
'dandischema>=0.3.4',
'dandischema==0.3.4',
'django>=3.1.2',
'django-admin-display',
'django-allauth',
Expand Down