Search code examples
cassandracassandra-node-driver

Cassandra cluster works with 2 nodes?


I have 2 nodes with replication factor = 1, it means will have 1 set of data copy in each node.

Based on above description when i use murmur3partitioner,

  1. Will data shared among nodes ? like 50% of data in node1 and 50% of data in node 2?
  2. when i read request to node 1 , will it internally connect with node 2 for consistency ?

And my intention is to make a replica and both nodes should server the request independently without inter communication.


Solution

  • First of all, please try to ask only one question at per post.

    I have 2 nodes with replication factor = 1, it means will have 1 set of data copy in each node.

    Incorrect. A RF=1 indicates that your entire cluster will have 1 copy of the data.

    Will data shared among nodes ? like 50% of data in node1 and 50% of data in node 2?

    That is what it will try to do. Do note that it probably won't be exact. It'll probably be something like 49/51-ish.

    when i read request to node 1 , will it internally connect with node 2 for consistency ?

    With a RF=1, no it will not. Based on the hashed token value of your partition key, it will be directed only to the node which contains the data.

    As an example, with a RF=2 with 2 nodes, it would depend on the consistency level set for your operation. Reading at ONE will always read only one replica. Reading at QUORUM will always read from 2 replicas with 2 nodes (after all, QUORUM of 2 equals 2). Reading at ALL will require a response from all replicas, and initiate a read repair if they do not agree.

    Important to note, but you cannot force your driver to connect to a specific Cassandra node. You may provide one endpoint, but it will find the other via gossip, and use it as it needs to.