Godswill
Godswill

Reputation: 35

Redis Sharding performance and o(1) time complexity for get key

please I need a simple explanation as regards this.

  1. Redis claims that time complexity for get key is o(1)

  2. As such, whether i have key value pair of 1,000,000 or 1,000,000,000,000,000 the time to get key is the same.

My question now is

I have a requirement to hold about 1 billion key-value pair, If memory is not a problem (meaning assume i have a single server with enough memory to hold that much data), is there any advantage of sharding? that is to say, will there be any performance advantage of seperating this 1billion key-value pair to 10 redis instances each holding 100million records as against just a single redis instance holding the entire records?

Thanks so much for your anticipated response

Upvotes: 1

Views: 271

Answers (1)

Itamar Haber
Itamar Haber

Reputation: 49942

There is a definite advantage to sharding in terms of performance, as it can use multiple CPU cores (ideally, one per shard). Being (mostly) single threaded, a single instance Redis can use only one core (and a little more). Sharding effectively increases the parallelism of the deployment, thus contributing positively to performance (but adding to the administrative overhead).

Upvotes: 2

Related Questions