A high-performance Rust-powered HTTP fetch library for Node.js, exposing a fetch-like API modeled on Rust’s reqwest
and designed for superior throughput under heavy concurrent load.
@valentech/rust-fetch Node.js native bindings to a fast, ergonomic Rust HTTP client
-
Reqwest-inspired API: Familiar
fetch(url, options)
signature and ergonomic builder patterns likereqwest::ClientBuilder
. - Native Neon Bindings: Written in Rust, compiled to a Node.js addon via Neon.
- Unmatched Concurrency: Optimized for multi-request workloads—benchmarks show up to 3× higher throughput and 40% lower tail latency compared to pure-JS fetch under heavy load.
- Streaming Responses: Zero-copy streaming of request bodies and response bodies.
-
Automatic TLS: Secure HTTPS via Rust’s
rustls
.
- Node.js v14 or higher (CommonJS)
- Yarn or npm
- Rust toolchain (stable Rust + Cargo)
- cross (for cross-compilation)
- Neon CLI (dev dependency)
Install via npm or Yarn:
yarn add @valentech/rust-fetch
# or
npm install @valentech/rust-fetch
This library exposes a single function:
-
rustFetch(url, options): A simple, one-off fetch call with the familiar
fetch
-style signature. Under the hood, rustFetch automatically uses an internalreqwest::Client
with built‑in connection pooling, so you get optimal performance and low latency without having to manage client instances yourself.
const { rustFetch } = require("@valentech/rust-fetch");
(async () => {
const response = await rustFetch("https://api.example.com/data", {
method: "GET",
});
if (!response.ok) throw new Error(`HTTP error ${response.status}`);
const data = await response.json();
console.log(data);
})();
-
Standard build:
yarn build # runs `cargo build --release && neon build`
-
Cross-compilation (e.g. ARM, musl):
yarn cross # runs `cross build --release && neon build`
You can also run each step directly:
# Compile Rust code (release) with JSON output
cargo build --release --message-format=json
# Package Neon addon
neon build
-
Tests:
yarn test
(runsnode test.js
)
Benchmarks were run on Node.js v14 against a local HTTP server at http://localhost:8080/albums
, using 10 000 requests in both sequential and fully parallel modes:
Library | Mode | Total Time (ms) | Throughput (rps) | Peak Memory (KB) |
---|---|---|---|---|
rustFetch | Sequential | 2 579 | 3 877 | 275 252 |
rustFetch | Parallel | 921 | 10 857 | 275 252 |
native fetch | Sequential | 2 938 | 3 403 | 547 408 |
native fetch | Parallel | 3 167 | 3 157 | 547 408 |
- Throughput: rustFetch delivers ~3 × higher request‑per‑second under full concurrency (10 857 rps vs. 3 157 rps).
- Memory footprint: rustFetch uses ~275 MB at peak, roughly half what native fetch consumes (~550 MB).
- Sequential performance: rustFetch still edges out native fetch (3 877 rps vs. 3 403 rps).
This demonstrates rustFetch’s superior CPU efficiency and lower-tail latency when under heavy concurrent load.
- Fork repository
yarn install
yarn build && yarn test
- Submit a pull request