Max
Max

Reputation: 8836

Do long running operations lock redis?

In Redis, some operations such as SINTERSTORE have

Time complexity: O(N*M) worst case where N is the cardinality of the smallest set and M is the number of sets.

In my use case, I expect to be comparing sets of upwards of 15,000 items each. Performing an N*M operation on these sets would be O(30,000). There is no time requirement for the operation, meaning I don't care how long it takes. My question is whether my Redis will lock while this calculation is happening. Any ideas?

Upvotes: 6

Views: 481

Answers (2)

Yiftach
Yiftach

Reputation: 504

The simple answer is "Yes", because Redis is based on a single threaded architecture.

The non-simple answer is "it depends" - if you shard your Redis in an optimized manner, only the shard that does this complex operation is blocked, the other shards are not.

Upvotes: 2

Or Neeman
Or Neeman

Reputation: 1216

Redis is single-threaded. It doesn't lock anything, but it won't process any other commands until that one finishes. So it's as if Redis were locked, which I think is what you meant.

See also: Locking and Redis

Upvotes: 1

Related Questions