Add configurable max concurrency for Azure blob downloads#1562
Open
jonathantims wants to merge 3 commits into
Open
Add configurable max concurrency for Azure blob downloads#1562jonathantims wants to merge 3 commits into
jonathantims wants to merge 3 commits into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds a new
download_max_connsetting (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 existingupload_max_connsetting that controls upload concurrency.Motivation
The Azure SDK's
download_blobmethod supports amax_concurrencyparameter 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— Addeddownload_max_connsetting (default:1) and passed it asmax_concurrencytodownload_blob().tests/test_azure.py— Added two tests: one verifying the default concurrency of1, and one verifying a custom value (5) is correctly forwarded.docs/backends/azure.rst— Documented the newdownload_max_conn/AZURE_DOWNLOAD_MAX_CONNsetting.CHANGELOG.rst— Added changelog entry under the Azure section.storages/__init__.py— Bumped version to1.14.7.Usage
Or via the storage class directly: