How does the internal encoding of Redis lists change as they grow, and what performance implications does this have?
Short answer
Redis stores small lists using a compact listpack encoding, similar to small hashes and sets, automatically switching to a doubly linked list structure called a quicklist once the list grows beyond a configurable size threshold, which trades some memory efficiency for better…
Advertisement
AModel answer
Redis stores small lists using a compact listpack encoding, similar to small hashes and sets, automatically switching to a doubly linked list structure called a quicklist once the list grows beyond a configurable size threshold, which trades some memory efficiency for better performance characteristics on larger lists with frequent additions and removals at both ends.
Example
OBJECT ENCODING mylist CONFIG GET list-max-listpack-size
Real-world example
A team storing many small activity log lists notices most of them stay within the compact listpack encoding threshold, keeping their overall memory usage lower than if every list had immediately switched to the larger quicklist structure.
Likely follow-ups
- What are the tradeoffs between listpack and quicklist encoding for lists?
- How do you adjust the size threshold that controls when this encoding switch happens?
Related topics