Routing policy and connection pool configuration

33 views
Skip to first unread message

Vivek Bhat

unread,
Jan 27, 2022, 2:05:15 PM1/27/22
to go...@googlegroups.com
Hi everyone,

Had a few questions,,

With gocql.TokenAwareHostPolicy(gocql.DCAwareRoundRobinPolicy("US Central")) and let’s say, gocql driver found the tablet server(that owns the table partition) as down… What happens next? Because the replication of this tablet is in “US East 2”. Will the driver re route the request to "US East2"?

Also,
The PoolConfig interface provides a way to configure the HostSelectionPolicy. How do I set up things like number of openConnections number of idleConnection and Connection timeout?

Thanks,
Vivek

Martin Sucha

unread,
Jan 28, 2022, 3:38:06 AM1/28/22
to Vivek Bhat, go...@googlegroups.com
Hello Vivek,

On Thu, Jan 27, 2022 at 8:05 PM Vivek Bhat <vivekbh...@gmail.com> wrote:
With gocql.TokenAwareHostPolicy(gocql.DCAwareRoundRobinPolicy("US Central")) and let’s say, gocql driver found the tablet server(that owns the table partition) as down… What happens next? Because the replication of this tablet is in “US East 2”. Will the driver re route the request to "US East2"?
That depends on the replication strategy you use for the keyspace (determines whether there are other replicas in the "US Central" DC or not) and whether you use https://pkg.go.dev/github.com/gocql/gocql#NonLocalReplicasFallback option. 

Without NonLocalReplicasFallback it selects:
1. replicas in local DC
2. non-replicas in local DC

With NonLocalReplicasFallback it selects:
1. replicas in local DC
2. replicas in remote DC
3. non-replicas in local DC

Also,
The PoolConfig interface provides a way to configure the HostSelectionPolicy. How do I set up things like number of openConnections number of idleConnection and Connection timeout?
See ClusterConfig.NumConns, ClusterConfig.ConnectTimeout

There isn't an option for idle connections.

Martin


This email, including attached files, may contain confidential information and is intended only for the use of the individual and/or entity to which it is addressed. If you are not the intended recipient, disclosure, copying, use, or distribution of the information included in this email and/or in its attachments is prohibited.
If you have received it by mistake, please do not read, copy or use it, or disclose its contents to others. Please notify the sender that you have received this email by mistake by replying to the email, and then delete the email and any copies and attachments of it. Thank you.

Vivek Bhat

unread,
Jan 28, 2022, 5:56:15 AM1/28/22
to Martin Sucha, go...@googlegroups.com
Hi Martin,

Thanks for quick reply.

So without NonLocalReplicasFallback if the table is not found in both replicas in local DC and non-replicas in local DC. 
Will it continue searching for replicas and non replicas in Remote DC?

Thanks,
Vivek Bhat

Martin Sucha

unread,
Jan 28, 2022, 12:36:46 PM1/28/22
to Vivek Bhat, go...@googlegroups.com
Hi Vivek,

On Fri, Jan 28, 2022 at 11:56 AM Vivek Bhat <vivekbh...@gmail.com> wrote:
So without NonLocalReplicasFallback if the table is not found in both replicas in local DC and non-replicas in local DC. 
Will it continue searching for replicas and non replicas in Remote DC?
Both options contact nodes in remote DCs eventually (if the RetryPolicy allows enough retry attempts).

I have checked the source code (https://github.com/gocql/gocql/blob/d73e6b1002a78700df43099dd3de4f8c4e4d1ea9/policies.go#L578-L620 and https://github.com/gocql/gocql/blob/d73e6b1002a78700df43099dd3de4f8c4e4d1ea9/policies.go#L314) to refresh my memory and it turns out my previous reply wasn't entirely accurate. Here is an updated version:

With NonLocalReplicasFallback it selects:
1. replicas in local DC
2. replicas in remote DCs
3. non-replicas in local DC
4. non-replicas in remote DCs

(steps 3-4 are regular DCAwareRoundRobinPolicy applied on nodes left after TokenAwareHostPolicy used up all replicas)

Without NonLocalReplicasFallback it selects:
1. replicas in local DC
2. non-replicas in local DC
3. nodes in remote DCs (does not look at whether a node is replica or not)

(steps 2-3 are regular DCAwareRoundRobinPolicy applied on nodes left after TokenAwareHostPolicy used up all local replicas)

Hope this helps,

Martin
Reply all
Reply to author
Forward
0 new messages