why is very slow to connect to cassandra cluster in cloud from local application using c# driver?

592 views
Skip to first unread message

Hongwei Liu

unread,
May 15, 2015, 1:49:56 PM5/15/15
to csharp-dr...@lists.datastax.com
hi,

my application solution is :
   - three cassandra nodes running in Windows Azure Virtual Machine, under hosted service 'http://xxx.cloudapp.net'
   - a local windows service written with c#, which use cassandra c# driver to manage data in the cassandra cluster

in the client application :

var Host = "xxx.cloudapp.net";
var User = "yyy";
var Password = "zzz";

var cluster = Cluster.Builder().AddContactPoint(Host)
                            .WithCompression(CompressionType.Snappy)
                            .WithLoadBalancingPolicy(new RoundRobinPolicy())
                            .WithCredentials(User, Password).Build();
var session = cluster.Connect();


but the call of 'cluster.Connect()' always takes about 3 to 5 minutes. 

this is quite slow. 

i want to know what cause this. 

how can i improve this? (i can cache the session for next use, but the first time to establish the connection is really quite slow)


Thanks in advance for your helps.

Hongwei

Jorge Bay Gondra

unread,
May 18, 2015, 3:00:25 AM5/18/15
to csharp-dr...@lists.datastax.com
Hi,
You can diagnose the connectivity issue by enabling tracing: 
// Specify the minimum trace level you want to see
Cassandra.Diagnostics.CassandraTraceSwitch.Level = TraceLevel.Info;
// Add a standard .NET trace listener
Trace.Listeners.Add(new ConsoleTraceListener());

Cheers,
Jorge


To unsubscribe from this group and stop receiving emails from it, send an email to csharp-driver-u...@lists.datastax.com.

Adin Aronson

unread,
Aug 7, 2019, 8:43:38 AM8/7/19
to DataStax C# Driver for Apache Cassandra User Mailing List
This was really helpful information. I can see that when I connect to Cassandra's external IP I can a bunch of local IPs that the driver is trying to connect to and can't (since they are in the cloud) I wonder how this can be solved...


On Monday, May 18, 2015 at 10:00:25 AM UTC+3, Jorge Bay Gondra wrote:
Hi,
You can diagnose the connectivity issue by enabling tracing: 
// Specify the minimum trace level you want to see
Cassandra.Diagnostics.CassandraTraceSwitch.Level = TraceLevel.Info;
// Add a standard .NET trace listener
Trace.Listeners.Add(new ConsoleTraceListener());

Cheers,
Jorge

On Fri, May 15, 2015 at 7:49 PM, Hongwei Liu <albert.h...@gmail.com> wrote:
hi,

my application solution is :
   - three cassandra nodes running in Windows Azure Virtual Machine, under hosted service 'http://xxx.cloudapp.net'
   - a local windows service written with c#, which use cassandra c# driver to manage data in the cassandra cluster

in the client application :

var Host = "xxx.cloudapp.net";
var User = "yyy";
var Password = "zzz";

var cluster = Cluster.Builder().AddContactPoint(Host)
                            .WithCompression(CompressionType.Snappy)
                            .WithLoadBalancingPolicy(new RoundRobinPolicy())
                            .WithCredentials(User, Password).Build();
var session = cluster.Connect();


but the call of 'cluster.Connect()' always takes about 3 to 5 minutes. 

this is quite slow. 

i want to know what cause this. 

how can i improve this? (i can cache the session for next use, but the first time to establish the connection is really quite slow)


Thanks in advance for your helps.

Hongwei

To unsubscribe from this group and stop receiving emails from it, send an email to csharp-driver-user+unsub...@lists.datastax.com.

Joao Reis

unread,
Aug 7, 2019, 9:34:09 AM8/7/19
to DataStax C# Driver for Apache Cassandra User Mailing List
Hi,

Are you setting the "rpc_address" property in the node's cassandra.yaml? Here's some documentation on this topic: https://docs.datastax.com/en/developer/csharp-driver/latest/features/address-resolution/

If you have multiple nodes that can not be accessed from the network where the application is running, then I would suggest providing a custom load balancing policy (like java driver's HostFilterPolicy). Keep in mind that query routing will not be optimal and performance will take a hit so you should not do this in production.

Best regards,

João Reis |  Senior Software Engineer - Drivers

joao...@datastax.com  |  datastax.com


DataStax-Constellation-Signature1.png



To unsubscribe from this group and stop receiving emails from it, send an email to csharp-driver-u...@lists.datastax.com.

--
To unsubscribe from this group and stop receiving emails from it, send an email to csharp-driver-u...@lists.datastax.com.

Adin Aronson

unread,
Aug 7, 2019, 10:05:47 AM8/7/19
to csharp-dr...@lists.datastax.com, Joao Reis

Hi Joao,


I figured out to use the Cluster.Builder().WithAddressTranslator(new ToPublicIpAddressTranslater()) option. Inside ToPublicIpAddressTranslater() I translated the local IPs to external IPs and this solved all my issues but I never would have even known about them if I hadn't come across your post about using Trace.


Thanks,

Adin

Reply all
Reply to author
Forward
0 new messages