OceanBase logo

OceanBase

A unified distributed database ready for your transactional, analytical, and AI workloads.

DEPLOY YOUR WAY

OceanBase Cloud

The best way to deploy and scale OceanBase

OceanBase Enterprise

Run and manage OceanBase on your infra

TRY OPEN SOURCE

OceanBase Community Edition

The free, open-source distributed database

OceanBase seekdb

Open source AI native search database

Customer Stories

Real-world success stories from enterprises across diverse industries.

View All
BY USE CASES

Mission-Critical Transactions

Global & Multicloud Application

Elastic Scaling for Peak Traffic

Real-time Analytics

Active Geo-redundancy

Database Consolidation

Resources

Comprehensive knowledge hub for OceanBase.

Blog

Live Demos

Training & Certification

Documentation

Official technical guides, tutorials, API references, and manuals for all OceanBase products.

View All
PRODUCTS

OceanBase Cloud

OceanBase Database

Tools

Connectors and Middleware

QUICK START

OceanBase Cloud

OceanBase Database

BEST PRACTICES

Practical guides for utilizing OceanBase more effectively and conveniently

Company

Learn more about OceanBase – our company, partnerships, and trust and security initiatives.

About OceanBase

Partner

Trust Center

Contact Us

International - English
中国站 - 简体中文
日本 - 日本語
Sign In
Start on Cloud

A unified distributed database ready for your transactional, analytical, and AI workloads.

DEPLOY YOUR WAY

OceanBase Cloud

The best way to deploy and scale OceanBase

OceanBase Enterprise

Run and manage OceanBase on your infra

TRY OPEN SOURCE

OceanBase Community Edition

The free, open-source distributed database

OceanBase seekdb

Open source AI native search database

Customer Stories

Real-world success stories from enterprises across diverse industries.

View All
BY USE CASES

Mission-Critical Transactions

Global & Multicloud Application

Elastic Scaling for Peak Traffic

Real-time Analytics

Active Geo-redundancy

Database Consolidation

Comprehensive knowledge hub for OceanBase.

Blog

Live Demos

Training & Certification

Documentation

Official technical guides, tutorials, API references, and manuals for all OceanBase products.

View All
PRODUCTS
OceanBase CloudOceanBase Database
ToolsConnectors and Middleware
QUICK START
OceanBase CloudOceanBase Database
BEST PRACTICES

Practical guides for utilizing OceanBase more effectively and conveniently

Learn more about OceanBase – our company, partnerships, and trust and security initiatives.

About OceanBase

Partner

Trust Center

Contact Us

Start on Cloud
编组
All Products
    • Databases
    • iconOceanBase Database
    • iconOceanBase Cloud
    • iconOceanBase Tugraph
    • iconInteractive Tutorials
    • iconOceanBase Best Practices
    • Tools
    • iconOceanBase Cloud Platform
    • iconOceanBase Migration Service
    • iconOceanBase Developer Center
    • iconOceanBase Migration Assessment
    • iconOceanBase Admin Tool
    • iconOceanBase Loader and Dumper
    • iconOceanBase Deployer
    • iconKubernetes operator for OceanBase
    • iconOceanBase Diagnostic Tool
    • iconOceanBase Binlog Service
    • Connectors and Middleware
    • iconOceanBase Database Proxy
    • iconEmbedded SQL in C for OceanBase
    • iconOceanBase Call Interface
    • iconOceanBase Connector/C
    • iconOceanBase Connector/J
    • iconOceanBase Connector/ODBC
    • iconOceanBase Connector/NET
icon

OceanBase Database Proxy

V4.1.0Enterprise Edition

  • What is ODP?
  • Installation and deployment
    • Deploy ODP by using the CLI
    • Deployment modes
  • Basic operations
  • Configuration parameter
    • Parameter description
    • Dynamically modifiable parameters
    • Parameters that are not dynamically modifiable
    • In-memory parameters
  • Connection management
  • Data routing
    • Factors affecting data routing
    • Routing strategies
    • ODP routing
    • Intra-tenant routing
    • Read/Write separation
  • High availability mechanism
    • Overview
    • High availability of ODP services
    • High availability of OceanBase Database
    • High availability testing
  • Security and protocols
  • Operation and maintenance
    • Troubleshooting
      • Troubleshooting logic
      • Monitoring logs
    • Performance analysis

Download PDF

What is ODP? Deploy ODP by using the CLI Deployment modes Basic operations Parameter description Dynamically modifiable parameters Parameters that are not dynamically modifiable In-memory parameters Connection management Factors affecting data routing Routing strategies ODP routing Intra-tenant routing Read/Write separation Overview High availability of ODP services High availability of OceanBase Database High availability testing Security and protocols Troubleshooting logic Monitoring logs Performance analysis
OceanBase logo

The Unified Distributed Database for the AI Era.

Follow Us
Products
OceanBase CloudOceanBase EnterpriseOceanBase Community EditionOceanBase seekdb
Resources
DocsBlogLive DemosTraining & Certification
Company
About OceanBaseTrust CenterLegalPartnerContact Us
Follow Us

© OceanBase 2026. All rights reserved

Cloud Service AgreementPrivacy PolicySecurity
Contact Us
Document Feedback
  1. Documentation Center
  2. OceanBase Database Proxy
  3. V4.1.0
iconOceanBase Database Proxy
V 4.1.0Enterprise Edition
  • V 4.3.6
  • V 4.3.4
  • V 4.3.3
  • V 4.3.2
  • V 4.3.1
  • V 4.3.0
  • V 4.2.3
  • V 4.2.2
  • V 4.2.0 and earlier

Routing strategies

Last Updated:2026-04-14 09:41:34  Updated
share
What is on this page
Overview
Primary zone-based routing
LDC-based routing
Random routing
Configure and view routing strategies

folded

share

Overview

Routing strategies help ODP select a suitable replica for SQL statements. The multiple replicas can be the multiple replicas selected during follower routing or during tenant server routing for statements such as select 1 from dual.

ODP implements three types of routing strategies:

  • Primary zone-based routing, which takes the top priority

  • LDC-based routing, which takes the second priority

  • Random routing, which takes the third priority

Primary zone-based routing

ODP sends an SQL request preferentially to the server where the primary zone is located. The zone where the leader is located is called the primary zone. Adopt this routing strategy in the following scenarios:

  1. In the high-performance deployment architecture commonly used for OceanBase Database, the primary zone of a tenant is deployed on one server. This mechanism reduces network overheads for a distributed system.

  2. During leader routing, ODP may fail to get the table name or calculate the partition ID. In this case, ODP can adopt this routing strategy to send the requests to the leader as far as possible.

LDC-based routing

LDC-based routing is a routing strategy based on location information, which includes the following attributes:

  • IDC: indicates a logical data center.

  • Region: indicates a city.

Both ODP and OBServers can set the LDC information. Based on the LDC information, ODP can determine the location relationship with an OBServer. After the LDC information is specified, ODP adopts LDC-based routing by default.

LDC settings for an OBServer

You can set the Region or IDC attribute for each zone of an OBServer. The Region attribute is usually set to the city name, which is case-sensitive. The IDC attribute specifies the data center where the zone is located. Generally, the data center name in lowercase is specified for the IDC attribute. The SQL statement is as follows:

alter system modify zone "z1" set region = "SHANGHAI";
alter system modify zone "z1" set idc = "zue";

Return result:

mysql> select * from DBA_OB_ZONES;
+-------+----------------------------+----------------------------+--------+-----+----------------+-----------+
| ZONE  | CREATE_TIME                | MODIFY_TIME                | STATUS | IDC | REGION         | TYPE      |
+-------+----------------------------+----------------------------+--------+-----+----------------+-----------+
| z1    | 2022-10-31 11:48:29.040552 | 2022-10-31 11:48:29.041609 | ACTIVE | zue | SHANGHAI       | ReadWrite |
+-------+----------------------------+----------------------------+--------+-----+----------------+-----------+
| z2    | 2022-10-31 11:48:29.040552 | 2022-10-31 11:48:29.041609 | ACTIVE | zue | SHANGHAI       | ReadWrite |
+-------+----------------------------+----------------------------+--------+-----+----------------+-----------+
| z3    | 2022-10-31 11:48:29.040552 | 2022-10-31 11:48:29.041609 | ACTIVE | ztg | HANGZHOU       | ReadOnly  |
+-------+----------------------------+----------------------------+--------+-----+----------------+-----------+
3 rows in set

LDC settings for ODP

You can configure LDC settings for ODP in one of the following ways. In this example, the sample zue IDC is used.

  • Set the LDC parameters when you start the obproxy process. This is the recommended method. Sample code:

    cd /opt/taobao/install/obproxy
    ./bin/obproxy -o proxy_idc_name=zue
    
  • Execute the ALTER statement on a support client tool to modify the ODP settings. Sample statement:

    mysql> alter proxyconfig set proxy_idc_name='zue';
    

Run the internal command show proxyinfo idc; of ODP to check the LDC configuration for ODP.

mysql> show proxyinfo idc;
+-----------------+--------------+-----------------+-----------------+--------------------------------------------------------+-------------+--------------------+
| global_idc_name | cluster_name | match_type      | regions_name    | same_idc                                               | same_region | other_region       |
+-----------------+--------------+-----------------+-----------------+--------------------------------------------------------+-------------+--------------------+
| zue             | obcluster    | MATCHED_BY_NONE | []              | [[0]"z1", [1]"z1", [2]"z2", [3]"z2", [4]"z3", [5]"z3"] | []          | []                 |
+-----------------+--------------+-----------------+-----------------+--------------------------------------------------------+-------------+--------------------+
| zue             | obcluster    | MATCHED_BY_IDC  | [[0]"SHANGHAI"] | [[0]"z1", [1]"z1", [2]"z2", [3]"z2"]                   | []          | [[0]"z3", [1]"z3"] |
+-----------------+--------------+-----------------+-----------------+--------------------------------------------------------+-------------+--------------------+
| zue             | obcluster    | MATCHED_BY_IDC  | [[0]"SHANGHAI"] | [[0]"z1", [1]"z1", [2]"z2", [3]"z2"]                   | []          | [[0]"z3", [1]"z3"] |
+-----------------+--------------+-----------------+-----------------+--------------------------------------------------------+-------------+--------------------+
3 rows in set

Note

  • If OceanBase Database is deployed in only one IDC, the LDC information is of little use, because the latency among servers in the same IDC is the same by default. If you still want to adopt the LDC-based routing strategy in this case, plan the LDC architecture, and set the LDC attributes for both the OBServer and ODP. If OceanBase Database is deployed across multiple IDCs, you can plan the LDCs based on the IDCs and city.

  • In some special cases, you can specify LDC settings by using the trick method to enable LDC-based routing. However, we do not recommend you do that.

Random routing

ODP adopts the random routing strategy when multiple replicas are still available for selection after the primary zone-based routing and LDC-based routing. If primary zone-based routing is not enabled or LDC-based routing is not configured, ODP directly uses random routing.

Configure and view routing strategies

Data routing is complex because different routing strategies are available. By default, ODP first perform leader routing and follower routing, and performs tenant server routing if no replica is available. If only one replica is selected, ODP directly routes the data to the replica. Otherwise, ODP routes the data based on routing strategies.

Primary zone-based routing and LDC-based routing are controlled by the following parameters:

  • enable_primary_zone: specifies whether to use the primary zone-based routing strategy. The value true indicates to use primary zone-based routing.

  • proxy_idc_name: specifies the name of the IDC. LDC-based routing is used when this parameter is specified.

If you want to use routing strategies other than the existing ones, you can modify the proxy_route_policy parameter to set the new strategy with the top priority. The following two routing strategies are frequently used, which are both related to weak reading.

  • FOLLOWER_FIRST: Requests are first routed to a follower, and are routed to the leader only when no follower is available.

  • FOLLOWER_ONLY: Requests are routed only to a follower. If no follower is available, an error is returned.

You can query the route_type field in ODP logs for the routing strategies used by ODP. For example, ROUTE_TYPE_LEADER indicates that leader routing is used. ROUTE_TYPE_NONPARTITION_UNMERGE_LOCAL indicates a more complex situation. The keywords are described as follows:

  • PARTITON: indicates to select a server with replica data, regardless of the replica type.

  • NONPARTITION: indicates to select a tenant server regardless of the table data distribution.

  • FOLLOWER: indicates to send the request to a follower.

  • LEADER: indicates to send the request to the leader.

  • UNMERGE: indicates to send the request to a server not in the progress of major compaction.

  • MERGE: indicates to send the request to a server in the progress of major compaction.

  • LOCAL: indicates to send the request to a server in the same IDC.

  • REMOTE: indicates to send the request to a server in a different IDC in the same city.

  • REGION: indicates to send the request to a server in another city.

  • READONLY: indicates to send the request to a server in a READONLY zone.

  • READWRITE: indicates to send the request to a server in a READWRITE zone.

  • DUP: indicates to send the request to a server where the replicated table is located.

Previous topic

Factors affecting data routing
Last

Next topic

ODP routing
Next
What is on this page
Overview
Primary zone-based routing
LDC-based routing
Random routing
Configure and view routing strategies