Skip to content

Add configurable max concurrency for Azure blob downloads#1562

Open
jonathantims wants to merge 3 commits into
jschneier:masterfrom
jonathantims:master
Open

Add configurable max concurrency for Azure blob downloads#1562
jonathantims wants to merge 3 commits into
jschneier:masterfrom
jonathantims:master

Conversation

@jonathantims

Copy link
Copy Markdown

Summary

This PR adds a new download_max_conn setting (env: AZURE_DOWNLOAD_MAX_CONN) to the Azure storage backend, allowing users to configure the maximum number of concurrent connections used when downloading a blob. This mirrors the existing upload_max_conn setting that controls upload concurrency.

Motivation

The Azure SDK's download_blob method supports a max_concurrency parameter to parallelise chunk downloads for large files, but django-storages had no way to configure it — downloads always used the SDK default. This change gives users control over download parallelism, which can significantly improve throughput for large blob downloads.

Changes

  • storages/backends/azure_storage.py — Added download_max_conn setting (default: 1) and passed it as max_concurrency to download_blob().
  • tests/test_azure.py — Added two tests: one verifying the default concurrency of 1, and one verifying a custom value (5) is correctly forwarded.
  • docs/backends/azure.rst — Documented the new download_max_conn / AZURE_DOWNLOAD_MAX_CONN setting.
  • CHANGELOG.rst — Added changelog entry under the Azure section.
  • storages/__init__.py — Bumped version to 1.14.7.

Usage

# settings.py
AZURE_DOWNLOAD_MAX_CONN = 4  # use 4 concurrent connections for downloads

Or via the storage class directly:

from storages.backends.azure_storage import AzureStorage

storage = AzureStorage(download_max_conn=4)

Currently, download_blob().readinto() doesn't expose a way to configure max_concurrency, meaning it always uses the Azure SDK default. This makes
it impossible to tune download parallelism the way AZURE_UPLOAD_MAX_CONN already allows for uploads.

Changes

 - Added a new download_max_conn setting, configurable via AZURE_DOWNLOAD_MAX_CONN (default: 1)
 - Passed max_concurrency to readinto() in AzureStorageFile._get_file()
 - Added tests for both the default and custom concurrency values

Usage

 # settings.py
 AZURE_DOWNLOAD_MAX_CONN = 4

Or when instantiating the storage directly:

 storage = AzureStorage(download_max_conn=4)

This follows the same pattern as the existing AZURE_UPLOAD_MAX_CONN / upload_max_conn setting.
Add CHANGELOG entry and Azure docs for the new download_max_conn /
AZURE_DOWNLOAD_MAX_CONN setting that configures max concurrency for
blob downloads.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant