Hello Stack overflow community!
I need some help in figuring out the proper way to establish connections with the help of express cassandra orm model in nodejs for my multi dc (total dc =2 ) cassandra setup.
We are currently using only 1 dc with express cassandra and so for the same we just give 2 seed node ip addresses in as contact points for express cassandra as shown below
models.setDirectory(__dirname + '/models').bind(
{
clientOptions: {
contactPoints: cassandraContactPoints,
protocolOptions: { port: 9042 },
keyspace: 'keyspace_name',
queryOptions: { consistency: models.consistencies.one }
},
ormOptions: {
defaultReplicationStrategy: {
class: 'NetworkTopologyStrategy',
replication_factor: 2,
},
createKeyspace: false,
dropTableOnSchemaChange: false
}
},
function (err) {
if (err) {
throw err;
} else {
console.log('connection established');
postDBConnection(models, 'keyspace name again');
}
}
Thing to note here is that we specify cassandraContactPoints as an array of just 2 nodes of our existing dc.
Since we are moving forward with a separate DC for analytical purposes, I would like to know if we should be giving the ip addresses of the new DC in the same array i.e. cassandraContactPoints ? We plan to use LOCAL_QUORAM and want our analytical apps to use only the analytical dc for all reads and writes.
I have tried reading the source for express cassandra and 'cassandra driver' modules but I am unable to figure out the solution>
Any help here would be extremely appreciated!
Giving contact point from another DC is never a good idea - most of drivers (don't remember of about Node.js driver) are performing the shuffle of the contact points, so it may first contact node in another DC, and extract DC name from that node's information, and will think that that DC is local to the application, so the LOCAL_QUORUM queries will be executed against Analytical DC, and this will lead to problems.
You can make your code more bullet proof against such things if you explicitly set DC name that is local for your application, instead of detecting it implicitly from contact points. See driver's documentation for details (in version 4.0, developer must specify the name of the local DC!)