Max number of values in one command

1,967 views
Skip to first unread message

Rudolph Froger

unread,
Mar 15, 2012, 11:02:18 AM3/15/12
to Redis DB
Hi,

I couldn't find in the Redis docs or elsewhere what the maximum
(sensible) number of arguments is for a Redis command. LPUSH for
example supports pushing multiple values to a list but I can't find
out what the maximum (sensible) number of values is. In my use case
I'll have to decide between pushing all values in one LPUSH or issue
one LPUSH per value or choose a balance between these two extremes. Is
this something I'd better test myself or is there a common best
practice for this situation?

Thanks,

Rudolph

Josiah Carlson

unread,
Mar 15, 2012, 12:54:04 PM3/15/12
to redi...@googlegroups.com
The maximum number of reasonable arguments varies from use-case to use-case.
* If you are looking to perform the most work with a single packet
round-trip, keep the total size of your command under 1500 bytes.
* If you are looking to insert data as fast as possible while also
trying to minimize the effects of insertions, benchmark the latency of
growing LPUSH sizes (with slowlog) and then pipeline LPUSH requests of
that size.

Regardless of what you do, pipelines (whether using MULTI/EXEC or not)
are your friends, as they reduce round trip times, and reduce
aggregate latency. When not using the multi-argument versions of
things, I will usually push about 1000 commands at a time, which
generally minimizes round-trip bulk-operation latency for me.

Regards,
- Josiah

> --
> You received this message because you are subscribed to the Google Groups "Redis DB" group.
> To post to this group, send email to redi...@googlegroups.com.
> To unsubscribe from this group, send email to redis-db+u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/redis-db?hl=en.
>

Didier Spezia

unread,
Mar 15, 2012, 1:06:23 PM3/15/12
to redi...@googlegroups.com
Hi,

I would say it depends if you also use pipelining on top of
using variadic commands or not.

If you do not use pipelining, then putting more items per
command will save a good number of roundtrips.

If you also use pipelining, then no roundtrip will be saved,
but CPU consumption on both client and server side will
still decrease.

It also depends on the size of your items.

The main drawback of building very large commands is
it may increase Redis latency (commands are serialized
because command execution is always atomic). It also
impacts the size of the connection query buffer associated
to the connection.

If you plan to optimize latency by targeting 1 packet roundtrips,
you may want to align the total query size on the size of the
ethernet packet (1500).

If you prefer to optimize throughput, using 10-100 items
depending on their size plus pipelining seems to give
good results. I have never used more than this (but if
your items are very small, you may want to try more ...)

Regards,
Didier.

Rudolph Froger

unread,
Mar 15, 2012, 3:49:23 PM3/15/12
to Redis DB
Thanks for the great answers. I'll try a few 'chunk' sizes that fit my
needs.

Rudolph Froger
Reply all
Reply to author
Forward
0 new messages