Search code examples
cassandradatastax-enterprise

How to handle read/write request in cassandra


I have 5 node cluster with 2 Cassandra,2 solr and 1 hadoop on EC2 with DSE4.5. My requirement is I dont want to hard code node IP address while requesting for Reading/writing from Cluster. I have to develop web service, thru which requester can send read/write request to my cluster and web service has to determine following

1) route read request to appropriate node. 2) route write request to appropriate node.

If there is any write request then it should direct to Cassandra node on basis of keyspace and replication factor. if it is a read request then request should route to Solr node (as I done indexing on solr) and if there is any analytic query then request should route to hadoop. And if any node goes down in that case response will not affect. Apart from dedicated request, is there any way to request a cluster ? by dedicated mean giving specific IP address for read and write.

Is any method or algorithm exist in DSE? or Is there any tool available in for this?


Solution

  • The Java driver should take care of all of that for you:

    http://www.datastax.com/documentation/developer/java-driver/2.0/common/drivers/introduction/introArchOverview_c.html

    For example:

    • Nodes discovery: the driver automatically discovers and uses all nodes of the Cassandra cluster, including newly bootstrapped ones

    • Configurable load balancing: the driver allows for custom routing and load balancing of queries to Cassandra nodes. Out of the box, round robin is provided with optional data-center awareness (only nodes from the local data-center are queried (and have connections maintained to)) and optional token awareness (that is, the ability to prefer a replica for the query as coordinator).

    • Transparent failover: if Cassandra nodes fail or become unreachable, the driver automatically and transparently tries other nodes and schedules reconnection to the dead nodes in the background.

    On the Solr query side, you can use the SolrJ load balancer, but you have to hard-wire the list of nodes to be used as coordinator nodes, but SolrJ will round robin for you.