- Total Dataset Volume: ~126 TB
- Total File Count: ~1.6 Million files
- Source Environment: On-premises enterprise NAS storage arrays (NFS/SMB multi-tier shares)
- Target Environment: Azure Blob Storage (General Purpose v2, hot/cool access tiers, secured via SAS tokens and private networking)
- Primary Tooling: Microsoft Azure azcopy (v10+), Bash orchestrator, Linux migration staging hosts
The following diagram illustrates the migration topography and contrasts the architectural differences between the initial serial loop (v1) and the optimized batch manifest pipeline (v3):
The original migration script followed an intuitive, linear shell pattern: discover files locally, loop through each path one by one, invoke azcopy copy, and inspect stdout to ensure success.
While functionally accurate, running this model against high-density file shares exposed three compounding bottlenecks:
The script spawned a separate azcopy copy process for every individual file. Because azcopy is a compiled Go binary, the operating system had to repeatedly fork subshells, initialize the Go runtime, spin up internal scheduler threads, parse environment variables and authentication tokens, and load system TLS root CA bundles from disk. Across 1.6 million files, process initialization alone burned immense CPU context-switching time.
Furthermore, every single invocation started with a cold network socket: a fresh TCP 3-way handshake and TLS 1.3 session negotiation occurred per file, preventing TCP slow-start from opening the congestion window and capping effective upload throughput at ~0.8 MB/s.
A logic flaw in the pre-check and transfer wrapper inadvertently triggered an evaluation branch that executed azcopy twice per file: once during an initial pre-check / existence evaluation, and a second time for the actual payload copy. Across 1.6 million files, this flaw committed the pipeline to 3.2 million independent process executions.
The script wrapped shell-level log parsing around every single azcopy call, redirecting output to temporary files and running string matching via grep:
This generated millions of disk write operations, created severe subshell I/O churn, and flooded the on-premises NAS with continuous metadata queries (getattr, lookup, open) that degraded storage array performance for other enterprise workloads.
To resolve the throughput crisis while keeping data safety guarantees intact, I progressed through three focused iterations:
- Execution Model: Single-file while-loop with double azcopy invocations and per-file Bash log parsing.
- Characteristics: High NAS controller metadata contention, 3.2M projected process forks, cold TCP/TLS connections on every file.
- Execution Model: Single-file loop with the double-execution bug eliminated and shell wrapper streamlined.
- Remediation: Consolidated the execution path so azcopy was invoked strictly once per file, while keeping all target folder structure translations, destination path sanitization, and error-logging guarantees intact.
- Result: Runtime dropped by ~60% on the same benchmark dataset (~13m 15s).
- Architectural Conclusion: While the bug fix delivered a measurable speedup, a 13-minute runtime for a small test batch was still far too slow for 126 TB. Serial process spawning, subshell log inspection, and connection teardown remained the fundamental architectural ceiling.
- Execution Model: Replaced the per-file execution loop with a validated batch manifest (--list-of-files).
- Core Shift: Instead of managing concurrency and file iteration in Bash, a single azcopy job per batch handles parallel transfers internally using its native Go concurrency engine.
- Preserved Guarantees: Retained exact target folder layouts, checksum verification, and validation rules, with orders of magnitude less chatter.
- Goroutine Worker Pools: A single long-lived process coordinates dozens of parallel transfer threads (AZCOPY_CONCURRENCY_VALUE), maximizing parallel throughput without OS process churn.
- Persistent HTTP/2 Connection Pooling: AzCopy keeps a pool of long-lived TCP/TLS sockets open. Files are streamed across multiplexed connections, eliminating handshake latency.
- Smooth Sequential Reads on NAS: The NAS sees continuous streaming reads rather than millions of discrete metadata lock requests.
The three iterations were benchmarked against identical datasets to measure execution time, process overhead, and network efficiency:
-
v1: Baseline (~33m 08s)
- Execution Model: 1 azcopy process per file + double-execution bug + per-call Bash log parsing
- Benchmark Runtime: ~33m 08s
- Outcome: High on-premises NAS metadata lock contention, 3.2M projected process forks, severe process overhead
-
v2: Bug Remediation (~13m 15s)
- Execution Model: 1 azcopy process per file (double-execution bug fixed + Bash wrapper cleanup)
- Benchmark Runtime: ~13m 15s (~60% faster than v1)
- Outcome: Removed duplicate invocations, but still fundamentally bound by serial process startup and connection teardown
-
v3: Validated Batch Engine (~1m 12s)
- Execution Model: Validated --list-of-files manifest (1 long-lived azcopy job per batch)
- Benchmark Runtime: ~1m 12s (72 seconds) (~27x faster)
- Outcome: 99.29% step duration reduction, internal Goroutine concurrency, persistent HTTP/2 socket reuse, zero NAS lock churn
To validate the batch manifest architecture under controlled conditions before rolling it out across production data shares, I executed a dedicated benchmark run with a 200-file manifest:
- Total Files in Batch: 200 files
- Total Payload Size: 2,952,800,324 bytes (~2.95 GB)
- Completed Transfers: 200 files (100%)
- Failed Transfers: 0
- Skipped Transfers: 0
- Elapsed Duration: 0.4673 minutes (~28 seconds)
- Final Job Status: Completed
This optimization reinforced core principles for large-scale enterprise cloud migrations:
Invoking CLI tools like azcopy, aws s3 cp, or gcloud storage inside a shell loop is an anti-pattern. While acceptable for dozens of files, it fails catastrophically at scale due to process initialization costs, memory allocation, and connection teardown.
In high-throughput storage pipelines, file discovery (manifest generation) should always be decoupled from data transport. Generating a sanitized --list-of-files manifest allows the transfer engine to stream at line speed without stalling for directory traversal.
When refactoring from serial to batch execution, log formats and telemetry structures change fundamentally. Always verify that monitoring and alerting wrappers parse the batch summary block rather than expecting legacy per-file stdout signatures.
Modern data transfer tools built in compiled languages (Go) feature sophisticated internal concurrency routines, multiplexed network clients, and memory ring buffers. Feeding these engines through validated batch manifests yields orders of magnitude higher throughput than any shell-level concurrency can achieve.
Azure Blob Storage · AzCopy v10 · Enterprise NAS · Data Migration · Performance Optimization · Linux Systems · Bash · Concurrency Engineering · SRE
