Logical Data Center (LDC) routing is a mechanism that resolves the problem of remote routing latency in the deployment mode of multiple IDCs across multiple regions for a distributed relational database.
As a typical high-availability distributed relational database system, OceanBase AI Database uses the Paxos protocol for log synchronization. OceanBase AI Database natively supports multi-region and multi-IDC deployment to ensure high disaster tolerance and reliability. However, every database deployed across multiple regions and IDCs has a latency issue caused by routing.
LDC routing is designed to resolve this problem. To use LDC routing, you must specify the region and IDC for each zone in an OceanBase AI Database cluster and specify the IDC name for ODP. When ODP receives a data access request, it routes and forwards the request based on the following priority order:
Select a replica that is in the same IDC and that is not undergoing a major compaction.
Select a replica that is in an IDC in the same region and that is not undergoing a major compaction.
Select a replica that is in the same IDC and that is undergoing a major compaction.
Select a replica that is in an IDC in the same region and that is undergoing a major compaction.
Randomly select a replica that is in an IDC in a different region and that is not undergoing a major compaction.
Randomly select a replica that is in an IDC in a different region and that is undergoing a major compaction.
To enable LDC routing, perform the following three steps:
Configure LDC settings for your OceanBase AI Database cluster.
Configure LDC settings for ODP.
Configure weak consistency read for the application.
Note
If you do not configure LDC settings, weak consistency read requests sent to a database deployed across different regions and IDCs are evenly distributed to all the replicas, including the leader and the followers. When a request accesses a replica in a remote IDC, the system response time significantly increases.
Configure LDC settings for your OceanBase AI Database cluster
Log in to the sys tenant as the root user from a client tool supported by OceanBase AI Database.
Execute the following statements to configure LDC settings:
obclient> ALTER SYSTEM MODIFY zone "z1" SET region = "SHANGHAI"; obclient> ALTER SYSTEM MODIFY zone "z1" SET idc = "zue";The parameters in the syntax are described as follows:
region: the region in which the Zone is located. Generally, you need to set the value to a city name. This parameter is case-sensitive.idc: the IDC in which the Zone is located. Generally, you need to set the value to an IDC name in lowercase.zone: the name of the Zone to be configured.An OceanBase AI Database cluster consists of multiple regions, each region contains multiple zones, and each zone corresponds to an IDC.
Execute the following statement to check whether the LDC settings have taken effect on the OBServer node.
Specifically, check whether the values of the Region and IDC fields for the corresponding Zone in the returned result match the values that you set.
obclient> SELECT * FROM oceanbase.DBA_OB_ZONES;
Configure LDC settings for ODP
You can configure an LDC for ODP in one of the following two ways. In this example, zue is the IDC name.
You can specify the parameters when you start an ODP process (recommended). Here is an example:
cd /opt/taobao/install/obproxy-1.5.5 ./bin/obproxy -o proxy_idc_name=zueExecute the
ALTERstatement on a supported client tool to modify the ODP settings. Here is an example:obclient> ALTER PROXYCONFIG SET proxy_idc_name= 'zue';
In this example, after you configure LDC for ODP, if an application is deployed in the zue IDC in Shanghai, after the application sends a weak consistency read request, the request is sent to the IDC in Shanghai.
You can execute the following statement to check whether the LDC settings have taken effect for ODP:
obclient> SHOW PROXYINFO IDC;
The return result is as follows:
Configure weak consistency read for applications
LDC routing applies only to weak consistency read scenarios. You can configure weak consistency read for applications in one of the following ways:
Use a hint in an SQL statement to enable weak consistency read. Here is a sample statement:
obclient> SELECT /*+read_consistency(weak)*/ * FROM t1;Specify a session variable. A session variable applies only to the current session. Here is a sample statement:
obclient> SET @@ob_read_consistency='weak';Specify a global variable. A global variable applies to all the connections to the tenant. Here is a sample statement:
obclient> SET @@global.ob_read_consistency='weak';