DEV Community

Javad Rajabzadeh
Javad Rajabzadeh

Posted on

Building an Open-Source Download Engine with Dynamic Range Stealing in Rust

Every download tool you’ve used—whether it’s IDM, aria2, or wget—shares a fundamental blind spot: when a connection starts choking or a mirror lags, they wait for a timeout to fire. They react only after things break.

To fix this, I built HYDRA 🐉, an open-source, multi-source download engine written entirely in Rust. It ships as both a curl/wget-compatible CLI and a cross-platform desktop application built with iced, designed to give you a smooth, familiar, IDM-like user experience across Windows, macOS, and Linux.

The Core Engineering Challenges

Traditional download managers split files statically or wait blindly for socket timeouts. If a single mirror throttles your connection halfway through, your overall speed drops to match the laggard while your tool sits idle, waiting for a dead timer to trigger.

Hydra addresses network instability using two core mechanisms:

  • Dynamic Range Stealing: Hydra continuously monitors every active mirror and connection. The moment one starts lagging, its remaining byte ranges are dynamically redistributed to faster peers on the fly—no server coordination and no restart required.

  • Statistical Collapse Detection: Instead of relying on naive timeouts, Hydra uses two-sided CUSUM and dual-window estimators. It tracks performance trends to spot a degrading connection before it actually dies, reacting to performance curves rather than outright failures.

Built with Rust and Iced

For the desktop experience, I wanted something native, fast, and lightweight. The GUI is built using the iced library, carefully styled and structured to mirror the intuitive layout and feel of Internet Download Manager (IDM), making it instantly comfortable whether you're switching from Windows or working across Linux and macOS.

Under the hood, Rust gives us safety and high concurrency, paired with several robust features:

  • Constant Memory Footprint: Positioned writes stream straight to disk. Downloading a 100 GB file uses the same minimal RAM footprint as downloading a 100 MB one.

  • Data Integrity: Per-chunk checksum manifests, remote hash verification, and Reed–Solomon erasure coding safeguard your downloads against local bitrot.

  • Drop-in Compatibility: Complete curl and wget flag compatibility means you can easily alias it and drop it into existing scripts.

  • Protocol Support: Full support for HTTP/HTTPS (via rustls), FTP, SOCKS4/4a/5, and CONNECT proxies.

How It Compares

  • vs. IDM: Open source, cross-platform, scriptable, and built for modern developer workflows.

  • vs. aria2: Replaces rigid static splitting with adaptive rebalancing and statistical stall detection.

  • vs. curl/wget: Retains your muscle memory while upgrading the engine underneath.

Get Involved

If you've ever fought flaky mirrors, slow CI artifact pulls, or massive dataset downloads, I’d love for you to give Hydra a spin.

Check out the project on GitHub, test it out, report issues, or contribute:
🔗 GitHub Repository

Feedback, code contributions, and stars are massively appreciated!

Top comments (0)