Background information
OceanBase Database Proxy (ODP) is now gradually maturing in functionality and stability, supporting features such as routing, high availability, and connection management. However, ODP lacks capabilities such as firewall and load balancing. To enhance the on-cloud competitiveness and user experience, ODP supports weight-based load-balanced routing in V4.3.2 and later. You can use the weadread_weight_zone parameter to specify a weight for each zone in an OceanBase cluster.
Considerations
This feature is supported only in ODP V4.3.2 and later.
The
weadread_weight_zoneparameter can be configured only at the tenant or VIP level, and must not be set to an empty string. Otherwise, an error is returned.If a zone is not configured with a weight, weak-consistency read requests are not routed to the zone.
If the weight of a zone is set to
0, weak-consistency read requests are not routed to this zone in normal cases, and are routed to this zone only when other zones with a non-zero weight are unavailable.After a weight is configured for a zone, a partition replica node in the zone has a higher priority than a dummy_ldc node. If dummy_ldc has multiple nodes, the nodes have the same priority and requests are randomly routed to them.
After a weight is configured for a zone, if no available replica is found after all replicas in the zone are retried, a disconnection is performed.
Examples
Configure VIP-level and tenant-level weights for zones to use weight-based load-balanced routing.
Notice
When you use the weight-based load-balanced routing feature, the configuration level of the routing strategy for weak-consistency read requests must be consistent with that of the weights. Otherwise, routing errors, such as login failure and internal request failure, may occur. At present, you can configure only VIP-level and tenant-level weights for zones.
replace into proxy_config(vid, vip, vport, tenant_name, cluster_name, name, value, config_level) values ('1', '10.10.10.1', '2881','tenent_1','cluster_1', 'proxy_route_policy','WEAKREAD_WEIGHT_LOAD_BALANCE','LEVEL_VIP'), ('2', '10.10.10.1', '3881','tenent_1','cluster_1', 'proxy_route_policy','WEAKREAD_WEIGHT_LOAD_BALANCE','LEVEL_VIP'), ('-1','','0','tenant_2','cluster_2','proxy_route_policy','WEAKREAD_WEIGHT_LOAD_BALANCE','LEVEL_TENANT');You can set
proxy_route_policytoWEAKREAD_WEIGHT_LOAD_BALANCEto use weight-based load-balanced routing.Configure weights for zones in the OceanBase cluster.
The following sample code configures VIP-level and tenant-level weights for the zones.
replace into proxy_config(vid, vip, vport, tenant_name, cluster_name, name, value, config_level) values ('1', '10.10.10.1', '2881','tenent_1','cluster_1', 'weakread_weight_zone','zone1:90;zone2:80;zone3:70','LEVEL_VIP'), ('2', '10.10.10.1', '3881','tenent_1','cluster_1', 'weakread_weight_zone','zone1:80;zone2:90;zone3:70','LEVEL_VIP'), ('-1','','0','tenant_2','cluster_2','weakread_weight_zone','zone1:80;zone2:70;zone3:90','LEVEL_TENANT');Note
The
weakread_weight_zoneparameter can be configured only at the tenant or VIP level. An error is returned if you configure the parameter at the cluster or global level.
References
For more information about weak-consistency read, see Weak-consistency read.
For more information about how to configure weak-consistency read, see Read/Write splitting.
For more information about the parameters mentioned above, see proxy_route_policy and weakread_weight_zone.