title: How does cassandra find the node that contains the data?
body: <p>I've read quite a few articles and a lot of question/answers on SO about Cassandra but I still can't figure out how Cassandra decides which node(s) to go to when it's reading the data.</p>
  
  <p>First, some assumptions about an imaginary cluster:</p>
  
  <ol>
  <li>Replication Strategy = simple</li>
  <li>Using Random Partitioner</li>
  <li>Cluster of 10 nodes</li>
  <li>Replication Factor of 5</li>
  </ol>
  
  <p>Here's my understanding of how writes work based on various Datastax articles and other blog posts I've read:</p>
  
  <ul>
  <li>Client sends the data to a random node</li>
  <li>The "random" node is decided based on the MD5 hash of the primary key.</li>
  <li><p>Data is written to the commit_log and memtable and then propagated 4 times (with RF = 5).</p></li>
  <li><p>The 4 next nodes in the ring are then selected and data is persisted in them.</p></li>
  </ul>
  
  <p>So far, so good.</p>
  
  <p>Now the question is, when the client sends a read request (say with CL = 3) to the cluster, how does Cassandra know which nodes (5 out of 10 as the worst case scenario) it needs to contact to get this data? Surely it's not going to all 10 nodes as that would be inefficient.</p>
  
  <p>Am I correct in assuming that Cassandra will again, do an MD5 hash of the primary key (of the request) and choose the node according to that and then walks the ring?</p>
  
  <p>Also, how does the network topology case work? if I have multiple data centers, how does Cassandra know which nodes in each DC/Rack contain the data? From what I understand, only the first node is obvious (since the hash of the primary key has resulted in that node explicitly).</p>
  
  <p>Sorry if the question is not very clear and please add a comment if you need more details about my question.</p>
  
  <p>Many thanks,</p>