Skip to main content

Overview

Auto-pipelining automatically batches multiple Redis commands into a single HTTP request, providing the performance benefits of manual pipelining without requiring explicit pipeline management.

How it works

When auto-pipelining is enabled (the default), commands issued in the same event loop tick are automatically batched:
Internally, the SDK:
  1. Collects all commands issued in the current tick
  2. Waits for the next tick (using Promise.resolve().then())
  3. Sends all collected commands in a single batch
  4. Returns individual results to each promise

Enabling auto-pipelining

Auto-pipelining is enabled by default. To explicitly enable or disable:
When disabled, each command executes as an individual HTTP request.

Usage patterns

Parallel operations

Execute multiple independent commands efficiently:

Sequential with batching

Issue commands sequentially in the same tick:

JSON operations

JSON commands are also auto-pipelined:

When commands are batched

Commands are batched when issued in the same event loop tick:

Performance comparison

Without auto-pipelining

With auto-pipelining

Monitoring pipeline batches

Track how many pipeline batches have been executed:

Error handling

Each command’s promise resolves or rejects individually:

Excluded commands

Some commands cannot be auto-pipelined and always execute individually:
  • scan, hscan, sscan, zscan - Cursor-based iteration
  • keys - Returns all keys
  • hgetall, hkeys - May return large datasets
  • lrange - May return large ranges
  • smembers - Returns all set members
  • zrange - May return large ranges
  • xrange, xrevrange - Stream ranges
  • flushdb, flushall - Destructive operations
  • dbsize - Database-wide operation
  • exec - Transaction execution
These commands execute as individual requests regardless of auto-pipelining settings.

Auto-pipeline vs manual pipeline

When to use auto-pipeline

  • Default choice for most applications
  • Serverless functions with multiple commands
  • Simplified code without manual pipeline management
  • When batching can happen naturally via Promise.all()

When to use manual pipeline

  • Need explicit control over batch boundaries
  • Want to see exactly which commands are batched
  • Building complex batch operations
  • Need transaction semantics with multi()

Real-world example

Serverless function with auto-pipelining:

Best practices

  1. Issue commands before awaiting: Let the SDK collect multiple commands
  2. Use Promise.all() for parallel operations
  3. Handle errors individually
  4. Monitor pipeline efficiency in development