#1373·hiredis

Large bulk-string replies (e.g. CLIENT LIST with many connected clients) require the entire reply in memory before any of it can be consumed

Author: fcostaoliveiraCreated Sep 13, 2026Updated Sep 13, 2026

Description

I believe this may be the same underlying issue as #616, but wanted to file a concrete real-world trigger for it: CLIENT LIST against a server with a large number of connected clients returns a single large bulk-string reply, and hiredis's reader (processBulkItem in read.c) won't begin producing a result until the entire bulk item is present in its internal buffer:

c
/* Only continue when the buffer contains the entire bulk item. */
if (r->pos+bytelen <= r->len) { ... }

For a server with tens of thousands of connected clients, this reply can be many hundreds of MB to multi-GB in size, all of which must be held in memory at once purely to read it — regardless of what the calling application actually intends to do with it (e.g. scan for one specific client, or just count connections).

Observed impact

Testing with an increasing number of connected clients showed memory usage during a single CLIENT LIST call scaling roughly linearly with connection count, reaching multi-GB for connection counts that aren't unusual for a busy, long-lived server (tens of thousands).

Relation to #616

This looks like a concrete, reproducible real-world case of the general limitation described in #616 ("commands and replies are stored entirely in memory"). Filing separately since #616 is fairly old and general — happy to have this closed as a duplicate if that's preferred, just wanted to attach a specific repro.

Suggested fix

The streaming callback API proposed in #616 would resolve this. Given the general proposal has been open for a while, would a narrower version — just for bulk-string replies specifically, letting a caller consume the reply in chunks as it arrives — be a smaller, more tractable first step?