title: Why do we need distributed lock in Redis if we partition on Key?
body: <p>Folks,</p>
  <p>I read thru <a href="https://stackoverflow.com/questions/37569680/why-we-need-distributed-lock-in-the-redis">Why we need distributed lock in the Redis</a> but it is not answering my question.</p>
  <p>I went thru the following</p>
  <ol>
  <li><a href="https://redis.io/topics/distlock" rel="nofollow noreferrer">https://redis.io/topics/distlock</a> to be specific <a href="https://redis.io/topics/distlock#the-redlock-algorithm" rel="nofollow noreferrer">https://redis.io/topics/distlock#the-redlock-algorithm</a>  and</li>
  <li><a href="https://redis.io/topics/partitioning" rel="nofollow noreferrer">https://redis.io/topics/partitioning</a></li>
  </ol>
  <p>I understand that partitioning is used to distribute the load across the N nodes. So does this not mean that the interested data will always be in one node? If yes then why should I go for a distributed lock that locks across all N nodes?</p>
  <p><strong>Example:</strong></p>
  <ol>
  <li>Say if I persist a trade with the id 123, then the partition based on the hashing function will work out which node it has to go. Say for the sake of this example, it goes to 0th node.</li>
  <li>Now my clients (multiple instances of my service) will want to access the trade 123.</li>
  <li>Redis again based on the hashing is going to find in which Node the trade 123 lives.</li>
  <li>This means the clients (in reality one instance among the multiple instances i.e only one client ) will  lock the trade 123 on the 0th Node.</li>
  <li>So why will it care to lock all the N nodes?</li>
  <li>Unless partitioning is done on a particular record across all the Nodes i.e
  Say a single trade is 1MB in size and it is partitioned across 4 Nodes with 0.25MB in each node.</li>
  </ol>
  <p>Kindly share your thoughts. I am sure I am missing something but any leads are much appreciated.</p>