gocql客户端如何选择正确的Tablet服务器来执行任何查询?

huangapple go评论92阅读模式
英文:

How does gocql client pick the right Tablet server, for any query?

问题

yugabyte集群有2个区域、3个可用区和6个节点的架构。

中央区域有4个节点,
东部区域有2个节点。

Node1(Master,TServer)位于美国东部
Node2(Master,TServer)位于美国中部1
Node3(TServer)位于美国中部1
Node4(TServer)位于美国东部
Node5(Master,TServer)位于美国中部2(Leader)
Node6(TServer)位于美国中部2

应用程序在中央区域运行。

应用程序使用的是YCQL驱动程序(yugabyte gocql client),目前配置为仅将SQL查询发送到Node2。


正如这里所提到的:
在许多情况下,这种转发将是纯粹的本地转发,因为CQL和Redis Cluster客户端都能够将请求发送到正确的服务器,避免了额外的网络跳跃。

1)上述关于CQL客户端的陈述是否指的是yugabyte gocql client这里提到:“该驱动程序可以根据分区键(优先选择本地数据中心)将查询路由到保存数据副本的节点。”

客户端驱动程序如何知道要发送请求的哪个Tablet Server?

2)如果是的,YCQL驱动程序的连接配置是否与中央区域的所有4个节点建立连接,使客户端驱动程序能够知道正确的Tablet Server以提高查询响应时间?

3)如果是的,YCQL驱动程序如何知道要发送查询请求(INSERT/UPDATE/SELECT)的正确Tablet Server?

英文:

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)


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.

  1. Is the above statement about CQL client referring to yugabyte gocql client? here it mentions: "The driver can route queries to nodes that hold data replicas based on partition key (preferring local DC)."

    How can a client driver know, which tablet server to send the request?

  2. if yes, does connection configuration of YCQL driver having connections with all 4 nodes(in central region), makes the client driver capable of knowing the correct tablet server, to send query? improving the query response time

  3. if yes, Hoes YCQL driver know, which is the right tablet server to send query request(INSERT/UPDATE/SELECT)?

答案1

得分: 1

客户端驱动程序如何知道要将请求发送到哪个表服务器?

驱动程序定期查询以下表格:

ycqlsh:system> select * from system.partitions;

在这个表格中,它可以找到表的分片方式以及片剂的位置。

当你发送一个查询时,你以驱动程序理解的方式传递分区键,并对它们进行哈希处理,从而知道要将它们发送到哪里。

如果是的话,YCQL驱动程序的连接配置是否与中央区域的所有4个节点建立连接,使得客户端驱动程序能够知道正确的表服务器以发送查询?从而提高查询响应时间。

是的。这应该与数据中心感知的查询路由结合使用:https://pkg.go.dev/github.com/gocql/gocql#hdr-Data_center_awareness_and_query_routing

如果是的话,YCQL驱动程序如何知道要将查询请求(INSERT/UPDATE/SELECT)发送到正确的表服务器?

使用与上述相同的逻辑。了解整个集群上的片剂位置。

英文:

> How can a client driver know, which tablet server to send the request?

The driver periodically queries this table:

ycqlsh:system> select * from system.partitions;

Where it finds how tables are split, and where the tablets are located.

When you send a query, you pass the partition-keys in a way the driver understands them and hashes them and knows where to send them.

> if yes, does connection configuration of YCQL driver having connections with all 4 nodes(in central region), makes the client driver capable of knowing the correct tablet server, to send query? improving the query response time

Yes. This should be combined with DC Aware query routing: https://pkg.go.dev/github.com/gocql/gocql#hdr-Data_center_awareness_and_query_routing

> if yes, Hoes YCQL driver know, which is the right tablet server to send query request(INSERT/UPDATE/SELECT)?

Using the same logic as above. Knowing the tablet locations on all the cluster.

huangapple
  • 本文由 发表于 2022年1月24日 11:43:33
  • 转载请务必保留本文链接:https://go.coder-hub.com/70828795.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定