Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

StackExchange.Redis StringSet Maximum Array Size

For the Redis users and for the StackExchange.Redis driver users, I am trying to initialize the cache by doing mass insertion. To do so, I have tried with a StringSet with an array of 20000 KeyValue and it's failing to time out.

My understanding is by using an array, it is doing an MSET command which should be faster than 20K SET commands. Is it? Has anyone running into this issue? How should I solve it?

Thanks for your help.

like image 776
Pascal B. Avatar asked Jul 11 '26 04:07

Pascal B.


1 Answers

The difference between multiple SET and MSET is not as big as you would think - about 10 bytes per item bandwidth, and if you use pipelining (perhaps even the FireAndForget command option): zero latency. But you could also just as easily switch to batches of (say) 100 items: again, this will have additional overhead of about 10 bytes per batch, which is nothing - and these batches could also be pipelined if you want. In either pipelined case, SE.Redis does some work to minimise packet fragmentation etc. Basically, the change I would make here is: don't sent massive batches. Send multiple smaller batches. A huge batch isn't going to give you the benefit you imagine.

like image 130
Marc Gravell Avatar answered Jul 13 '26 16:07

Marc Gravell