From the database cluster(given below), to set the HostSelectionPolicy
, How do I know the name of datacenter(dc1
)? Is it the name of datacenter where application is running?
yugabyte cluster has 2 regions, 3 AZs, 6 node architecture.
4 nodes in central region,
2 nodes in east region
Node1 (Master, TServer) US-east
Node2 (Master, TServer) US-central-1
Node3 (TServer) US-central-1
Node4 (TServer) US-east
Node5 (Master, TServer) US-central-2 (Leader)
Node6 (TServer) US-central-2
Application is running in central region.
Application is using YCQL driver(yugabyte gocql client) that is currently configured to send SQL queries to Node2(only). Goal is to enable the driver to have connections for all tablet leaders(in central region)
As mentioned here:
In many cases, this forwarding will be purely local, because both CQL and Redis Cluster clients are capable of sending requests to the right server and avoiding an additional network hop.
For this, driver documentation says to provide the list of all tablet leaders and the hostselectionpolicy(shown below):
cluster := gocql.NewCluster("192.168.1.1", "192.168.1.2", "192.168.1.3")
cluster.PoolConfig.HostSelectionPolicy = gocql.TokenAwareHostPolicy(gocql.DCAwareRoundRobinPolicy("dc1"))
Can you paste the --placement_cloud
, --placement_region
, --placement_zone
for the servers?
@dorian_yugabyte
How to view --placement_cloud
, --placement_region
, --placement_zone
values through yugaware UI interface? Is it “cloud info” column?
You can look at them on http://tserverip:9000/varz
, http://masterip:7000/varz
, or on http://yb-master-ip:7000/tablet-servers
on the list of yb-tablet servers.
@dorian_yugabyte
For your question: Can you paste the --placement_cloud
, --placement_region
, --placement_zone
for the servers?
Below are the values for all 6 nodes:
Node1:
--placement_cloud=onprem
--placement_region=US East 2
--placement_zone=useast2-1
Node2:
--placement_cloud=onprem
--placement_region=US Central
--placement_zone=uscentral-1
Node3:
--placement_cloud=onprem
--placement_region=US Central
--placement_zone=uscentral-1
Node4:
--placement_cloud=onprem
--placement_region=US East 2
--placement_zone=useast2-1
Node5:
--placement_cloud=onprem
--placement_region=US Central
--placement_zone=uscentral-2
Node6:
--placement_cloud=onprem
--placement_region=US Central
--placement_zone=uscentral-2
Application(using gocql driver) is in central region.
What should be the value of dc1
in gocql.TokenAwareHostPolicy(gocql.DCAwareRoundRobinPolicy("dc1"))
?
@sham_yuga - The value of gocql.TokenAwareHostPolicy(gocql.DCAwareRoundRobinPolicy())
should be “US Central
” which corresponds to --placement_region
. This is the value that will be in system.local
and system.peers
as the datacenter
.
Hope this helps.
Alan
1 Like
@Alan_Caldera
If I set gocql.TokenAwareHostPolicy(gocql.DCAwareRoundRobinPolicy("US Central"))
and let’s say, gocql driver found the tablet server(that owns the table partition) in the central region, as down… What happens next? Because the replication of this tablet is in “US East 2”. How does gocql driver know that the query has to be sent to the tablet server in east region?
@sham_yuga
It knows the location of every tablet peer/leader for all tables/indexes in the whole cluster.