2

When creating a new namespace in Cassandra, we need to give a number for a replication factor. Ex: enter image description here

Does the number, that we are giving as the replication factor, determine the number of nodes that initially create to store the replicate data? Can anybody give a clear clarification about what that replication factor does?

Mohamed Ibrahim Elsayed
  • 2,734
  • 3
  • 23
  • 43
Sarah117
  • 91
  • 1
  • 7

2 Answers2

3

It will not create the number of nodes specified. It just means the number of copies of data. For instance if your cluster is having 5 nodes, your write will be replicated(written) to 3 different nodes depending on the token range it falls. Coming to SimpleStrategy its asn implementation where it does not consider rack or dc's into consideration when replicating.

  • Thank you. DO you know how to give the number of nodes that I need to create? – Sarah117 Nov 17 '18 at 07:25
  • 1
    The number of nodes (i.e., actual machines) you need to have depends on many factors such as how much data you have (e.g., you may need 100 nodes just to contain enough disks for all the data), and the request load (e.g., if one node can only do 10,000 requests per second and you get 1 million per second, you need 100 nodes). But if you have 100 nodes, it doesn't mean that each piece of data needs to be replicated 100 times! This is where RF (replication factor) comes in. If RF=3, each piece of data is replicated on just 3 of these 100 nodes. – Nadav Har'El Nov 18 '18 at 13:15
2

The explanation @Praneeth Gudumasu given for replication_factor is true. The number of nodes in a Cassandra cluster is not something you "give", you can actually connect as many number of nodes as you wish: https://docs.datastax.com/en/cassandra/3.0/cassandra/operations/opsAddNodeToCluster.html

and each time you connect a new node it is assigned a token range as per Cassandra's architecture. If you don't know how many nodes you need for your application I suggest running a performance test with data size approaching the size you would be inserting in your real application, then try to execute some queries (concurrently) and see with how many nodes you would get a reasonable response time for your queries.

Mohamed Ibrahim Elsayed
  • 2,734
  • 3
  • 23
  • 43
  • Thank you. Could you please tell me a good tool with the documentation to do a performance test? – Sarah117 Nov 19 '18 at 04:19
  • 1
    You can use a tool like cassandra-stress tool: https://docs.datastax.com/en/cassandra/3.0/cassandra/tools/toolsCStress.html or you can use Docker to start a Cassandra cluster, it is preferred to start each docker container on a separate machine for a more realistic performance test. Then you need to write code in your preferred languange with a client able to connect to the cluster you have set up in order to insert and perform queries on your cluster, for me I used datastax driver in java it supports performing queries either synchronously or asynchronously (asynchronously is more realistic) – Mohamed Ibrahim Elsayed Nov 20 '18 at 01:20