← back to blog

Node.js proxy rotation for mobile IPs: the patterns that actually ship

Your Node scraper picks the same proxy every time. Axios won’t rotate on its own. Fetch doesn’t even know what a proxy is without help. Here are the rotation patterns that actually ship in 2026: undici, axios, got, a stats-tracking pool, and a fifty-worker queue.

Node combines native concurrency, mature HTTP libraries, and a deployment story that fits Docker, Lambda, or Cloudflare Workers cleanly. But built-in fetch doesn’t natively support an HTTP CONNECT proxy. You need an Agent. By the end of this article you’ll have rotation working in undici, axios, and got, plus a worker pool that drives a mobile proxy gateway across hundreds of concurrent sessions.

Three things to cover: the basic rotation with undici and axios, a class-based pool that tracks per-proxy health, and a queue-based worker pool with sticky sessions and error classification.

The minimum rotation with axios

Axios is still the workhorse of Node HTTP code. The pattern loads a list of mobile proxy URLs, picks one per request, and applies it via httpsAgent.

That’s fine for jobs under a few thousand requests per minute. The catch is that the agent gets created per request, which restarts the TLS handshake every time. For higher throughput, cache your agents instead of building a new one per call.

Agent reuse lets the connection keep TCP and TLS sessions warm, cutting latency by forty to sixty percent on small requests.

Modern rotation with undici

Undici is the recommended HTTP client for new Node code as of 2026. Its ProxyAgent is built for the CONNECT-tunnel pattern that mobile proxies need, and it integrates with global fetch directly.

Undici dispatchers are pooled connections under the hood. For raw throughput, undici typically beats axios by two times on small payloads, because it skips the userland buffering that axios layers on top.

A stats-tracking pool

At scale, the right abstraction is a pool that tracks per-proxy health. Node makes this elegant with classes.

The pool retires misbehaving endpoints into cooldown and rehydrates them automatically. If everything ends up benched, a healthy pool returns the full list rather than deadlocking. Treat that as a signal to alert, not something to silently swallow.

A queue-based worker pool

For high concurrency, fan out N worker promises against a shared queue. Think ten thousand URLs across fifty concurrent workers.

The shared queue can just be an array, because Node’s single-threaded event loop guarantees queue.shift() is atomic. No locking, no race conditions. If you need to scale beyond one Node process, swap to a Redis-backed queue with BullMQ.

Sticky sessions

Sticky sessions in Node work the same way they do in Python. Bake a session token into the username.

A deterministic hash means the same account always lands on the same egress IP. That keeps cookies and IP reputation coherent across runs.

Error classification

A 429 means slow down. A 403 means rotate. A 502 means retry. A 407 means fix your auth. Build a centralized classifier and reuse it everywhere you make a request.

That one function is what turns a fragile rotation script into one that can handle the messy reality of public internet scraping.

Production checklist

Set explicit timeouts at every layer. Node’s default is to hang forever. Use AbortSignal.timeout(20000) on every fetch, plus an outer per-job deadline. Log every proxy ID and status. Instrument success rate per proxy, and alert if it drops below seventy percent over an hour. Stream large responses through r.body.getReader() to keep memory bounded. Never store every response in an array; that path leads to an out-of-memory crash.

For deployment, prefer PM2 or Kubernetes with liveness probes. Mobile proxy traffic is bursty, and Node’s garbage collection pauses interact badly with long-lived TLS connections. Restart workers regularly to keep memory steady.

This is the exact rotation stack running on our own Node fleet, driving real Singapore mobile IPs across Singtel, StarHub, and M1.

If you want to run this stack against real Singapore mobile IPs, check out Singapore Mobile Proxy.

Get new guides and videos first — join the Telegram channel.

ready to try Singapore mobile proxies?

24-hour free trial. no credit card required.

start free trial
message me on telegram