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 Best Practices

All Versions

  • Deploy
    • Configuration guide for read-write splitting in AP scenarios
    • Best practices for read-write splitting
  • Migrate
    • Data transfer solutions in OceanBase Database
    • Overview on data migration
    • Best practices for importing data files to OceanBase Database
    • Best practice for migrating data from other databases to OceanBase Database
    • Massive data migration strategy
    • Best practices for migrating data from MyCat to OceanBase Database
    • Best practices for migrating PostgreSQL to OceanBase MySQL-compatible mode
  • Route
    • ODP routing best practices
  • Table Design
    • Best practices for table design and index optimization
    • Best practices for creating indexes on large tables
    • Best practices for database development
  • Develop
    • Best practices for connecting Java applications to OceanBase Database
    • Best practices for integrating Spark Catalog with OceanBase Database
    • Best practices for achieving optimal performance in batch DML using JDBC and OBServer
    • Best practices for bulk data cleanup in OceanBase Database
    • Best practices for PDML processing in OceanBase Database
    • Best practices for hot tables in OceanBase Database
    • Best practices for auto-increment columns and sequences in OceanBase Database
  • Manage
    • Best practices for resource throttling
    • Best practices for data load balancing
    • Best practices for security certification
    • Best practices for access control
    • Best practices for data encryption
  • Diagnose
    • Best practices for log interpretation in common scenarios
    • Best practices for end-to-end tracing
    • Best practices for using obdiag to collect performance information
    • Best practices for using obdiag to collect diagnostic information of parallel and slow SQL statements
    • Best practices for troubleshooting OceanBase Database performance issues
  • Performance Tuning
    • Best practices for handling slow queries
    • Best practices for collecting statistics to generate an efficient execution plan
    • Best practices for updating hotspot rows
    • Best practices for large object storage performance
    • Best practices for semi-structured storage performance
    • Best practices for OceanBase materialized views
  • Cloud Database
    • Best practices for achieving high availability through cross-cloud active-active deployment
    • High availability through primary and standby databases across clouds
    • High host CPU usage
    • Best practices for read/write splitting in OceanBase Cloud

Download PDF

Configuration guide for read-write splitting in AP scenarios Best practices for read-write splitting Data transfer solutions in OceanBase Database Overview on data migration Best practices for importing data files to OceanBase Database Best practice for migrating data from other databases to OceanBase Database Massive data migration strategy Best practices for migrating data from MyCat to OceanBase Database Best practices for migrating PostgreSQL to OceanBase MySQL-compatible mode ODP routing best practices Best practices for table design and index optimization Best practices for creating indexes on large tables Best practices for database development Best practices for connecting Java applications to OceanBase Database Best practices for integrating Spark Catalog with OceanBase Database Best practices for achieving optimal performance in batch DML using JDBC and OBServer Best practices for bulk data cleanup in OceanBase Database Best practices for PDML processing in OceanBase Database Best practices for hot tables in OceanBase Database Best practices for auto-increment columns and sequences in OceanBase Database Best practices for resource throttling Best practices for data load balancing Best practices for security certification Best practices for access control Best practices for data encryption Best practices for log interpretation in common scenarios Best practices for end-to-end tracing Best practices for using obdiag to collect performance information Best practices for using obdiag to collect diagnostic information of parallel and slow SQL statements Best practices for troubleshooting OceanBase Database performance issues Best practices for handling slow queries Best practices for collecting statistics to generate an efficient execution plan Best practices for updating hotspot rows Best practices for large object storage performance Best practices for semi-structured storage performance Best practices for OceanBase materialized views Best practices for achieving high availability through cross-cloud active-active deployment High availability through primary and standby databases across clouds High host CPU usage Best practices for read/write splitting in OceanBase Cloud
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 Best Practices
  3. master
iconOceanBase Best Practices
master
  • master

Configuration guide for read-write splitting in AP scenarios

Last Updated:2025-06-11 04:02:43  Updated
share
What is on this page
Background information and objectives
Configuration methods
Method 1: Configure columnstore replicas (core method for AP acceleration)
Method 2: Enable weak-consistency read (prerequisites for routing AP requests)
Method 3: Configure resource isolation for large queries
Typical configuration examples
Example 1: Dedicated routing for columnstore replicas
Example 2: Proximity-based routing for AP requests across data centers
Appendix 1: Description of key parameters
Appendix 2: ODP routing policies and LDC basics
Random routing policy
LDC configuration (optional)
References

folded

share

Background information and objectives

In hybrid transactional and analytical processing (HTAP) scenarios, both online transaction processing (OLTP) and online analytical processing (OLAP) workloads run on the same database cluster. OLAP requests, due to their high resource consumption, might impact the performance of critical OLTP operations. Therefore, we typically use a read-write splitting strategy, routing some of the read requests to follower replicas. This approach helps reduce the resource contention caused by complex analytical computations and minimizes the impact on the response time of online transactions.

OceanBase achieves the following objectives through columnstore replicas and OceanBase Database Proxy (ODP) routing policies:

  • OLTP requests: Use leader replicas to ensure high performance and data accuracy.
  • AP requests: Create columnstore replicas to accelerate analytical queries and achieve resource isolation.

Version requirements: columnstore replicas are supported starting from OceanBase Database V4.3.3 and OceanBase Cloud Platform (OCP) V4.3.3.

Configuration methods

Method 1: Configure columnstore replicas (core method for AP acceleration)

Challenge:

  • AP requests require high-performance analytics, but resources of OLTP leader replicas are limited.
  • Rowstore replicas cannot simultaneously meet the low latency demands of OLTP and the high throughput requirements of AP requests.

OceanBase Database V4.3.3 and later allow you to create columnstore replicas for AP requests.

Deploy columnstore replicas and configure ODP in an OceanBase cluster

Scenario Recommended approach Applicable phase Recommended deployment method
New analytical business Create a tenant with columnstore replicas System initialization Method 1 described below
Expanding analytical capabilities for existing businesses Add columnstore replicas Business expansion phase Method 2 described below

Method 1: Create a new tenant with columnstore replicas

  1. Configure resource units and resource pools. Example SQL statements:

    CREATE RESOURCE UNIT unit1, MAX_CPU=5, MIN_CPU=5, MEMORY_SIZE= '32G', MAX_IOPS=10000, MIN_IOPS=5000, LOG_DISK_SIZE=5301023539200;
    CREATE RESOURCE POOL pool1 UNIT='unit1', UNIT_NUM = 1, ZONE_LIST = ('zone1','zone2','zone3');
    
  2. Create a tenant with specified locality. Example SQL statement:

    CREATE TENANT tenant_c LOCALITY = 'F@zone1,F@zone2,C@zone3', primary_zone='zone1;zone2,zone3', RESOURCE_POOL_LIST=('pool1') SET ob_tcp_invited_nodes = '%';
    
  3. Deploy and configure ODP.

For more information about how to deploy columnstore replicas, see Use columnstore replicas.

Method 2: Add columnstore replicas to an existing tenant

  1. Add a new zone to the cluster and add nodes to the new zone. For more information, see Add a zone and Add a node.

  2. Create new resource units and resource pools. Example SQL statements:

    CREATE RESOURCE UNIT unit2, MAX_CPU=5, MIN_CPU=5, MEMORY_SIZE= '32G', MAX_IOPS=10000, MIN_IOPS=5000, LOG_DISK_SIZE=5301023539200;
    CREATE RESOURCE POOL pool2 UNIT = 'unit2', UNIT_NUM = 1, ZONE_LIST = ('zone4');
    ALTER TENANT tenant_c RESOURCE_POOL_LIST = ('pool1','pool2');
    
  3. Specify new locality for the tenant. Example SQL statement:

    ALTER TENANT tenant_c LOCALITY = 'F@zone1,F@zone2,F@zone3,C@zone4';s
    
  4. Deploy and configure ODP.

For more information about how to deploy columnstore replicas, see Use columnstore replicas.

Configure a read-only columnstore replica through OCP

You can also configure a read-only columnstore replica in the OCP console in a more convenient and simpler way.

  1. Add a read-only columnstore replica:

    • Case 1: Add a zone to an existing cluster

      In the OCP console, go to the corresponding cluster and add a new zone. You need to fill in the information of the new zone, select the server, and set the configurations.

    • Case 2: Add a replica to a tenant where a read-only columnstore replica needs to be created.

      After adding a zone, go to the tenant of the corresponding cluster and add a read-only columnstore replica for the tenant.

  2. Add an independent ODP: If required, create an independent ODP exclusively for AP requests.

  3. Configure read-write splitting: After the read-only columnstore replica is added, configure the read-write splitting strategy. For more information, see ODP routing best practices.

For more information about how to deploy a dedicated ODP and handle weak read requests, see Use columnstore replicas.

Method 2: Enable weak-consistency read (prerequisites for routing AP requests)

Challenge: AP requests need to access follower replicas, but the default routing policy is strong consistency.

AP requests must access follower or columnstore replicas through weak consistency reads. The configuration method is as follows:

-- Global session setting (recommended)  
SET GLOBAL OB_READ_CONSISTENCY='WEAK';  

-- Alternatively, you can configure this parameter at the ODP level:  
ALTER PROXYCONFIG SET OBPROXY_READ_CONSISTENCY=1;  -- 1 indicates weak consistency.

Method 3: Configure resource isolation for large queries

Challenge: Large AP queries may occupy excessive CPU resources, resulting in latency in OLTP requests.

OceanBase Database uses parameters to mange the resource consumption of large queries, preventing them from blocking OLTP workloads and reducing their impact on smaller queries. By configuring these parameters, you can effectively limit the resource usage of AP queries to avoid blocking OLTP operations. The configuration steps are as follows:

ALTER SYSTEM SET LARGE_QUERY_THRESHOLD = '10s';     -- Queries exceeding 10 seconds are considered large queries (default is 5 seconds)
ALTER SYSTEM SET LARGE_QUERY_WORKER_PERCENTAGE = 25; -- Large queries can only use 25% of CPU resources (default is 30%)

OceanBase Database limits the number of active worker threads available to large queries within a tenant, thereby restricting the maximum CPU resources they can use. This ensures that sufficient CPU resources remain available for executing OLTP workloads, such as small transactional operations. As a result, OLTP workloads, which are highly sensitive to response times, are guaranteed enough CPU resources to execute efficiently and without delay.

It is important to note, however, that while OceanBase Database can allocate resources between large queries and OLTP workloads, the large_query_threshold parameter should be configured within a reasonable range. Setting it too high may allow large queries to consume excessive system CPU resources, potentially causing slower OLTP response times or even queue backlog issues.

Typical configuration examples

Example 1: Dedicated routing for columnstore replicas

Scenario: Analyze user behavior data after a major e-commerce promotion.

Procedure:

  1. Create a zone (zone5) with columnstore replicas and bind it to the dedicated ODP for analytical requests.

  2. Set the routing policy:

    ALTER PROXYCONFIG SET PROXY_ROUTE_POLICY="follower_only";  
    
  3. Verify the routing configuration:

    EXPLAIN SELECT * FROM analysis_table WHERE region = 'east';  
    -- Confirm that the data source in the plan is zone5.  
    

Advantages:

  • Enhances aggregation calculations (like SUM and GROUP BY) using columnar storage.
  • Completely isolates OLAP and OLTP resources.

Example 2: Proximity-based routing for AP requests across data centers

Scenario: In a cross-region deployment, AP requests are routed to the nearest columnstore replica.

Procedure:

  1. Bind the zone to a geographic location:

    ALTER SYSTEM MODIFY ZONE "zone5" SET REGION="SHANGHAI", IDC="idc5";  -- The data center where the rowstore replica is located.  
    
  2. Configure the routing preference:

    ALTER PROXYCONFIG SET PROXY_ROUTE_POLICY="follower_first";  
    

Advantages:

  • AP requests from the Shanghai data center are routed to the columnstore replica in zone5 first, minimizing cross-region latency.

Appendix 1: Description of key parameters

Parameter Description Recommended value
OBPROXY_READ_CONSISTENCY Specifies the default read consistency level of ODP. (1 indicates weak consistency.) 1
PROXY_ROUTE_POLICY The routing policy. (follower_only is recommended for AP scenarios.) follower_only
LARGE_QUERY_THRESHOLD The threshold for large queries. A resource limit is triggered after the query times out. 10s (You can adjust it as needed based on business response.)
LARGE_QUERY_WORKER_PERCENTAGE The maximum percentage of CPU resources that can be occupied by large queries. 25~30

Appendix 2: ODP routing policies and LDC basics

Random routing policy

ODP supports three routing policies. To ensure that read requests with weak consistency are prioritized to the follower replica, you need to set the proxy_route_policy parameter for ODP.

  • If you set it to FOLLOWER_FIRST, the request is preferentially sent to the follower replica. If the follower replica is unavailable, the request is sent to the leader replica.

    ALTER PROXYCONFIG SET PROXY_ROUTE_POLICY="follower_first";  
    

- If you set it to `FOLLOWER_ONLY`, the request is randomly sent to the follower replica. If the follower replica is unavailable, an error is returned.

 ```sql  
 ALTER PROXYCONFIG SET PROXY_ROUTE_POLICY="follower_only";  

LDC configuration (optional)

In typical AP scenarios, columnstore replicas are created separately, and LDC routing does not need to be configured. If read-write splitting is implemented in the cluster, refer to this section to learn how to optimize routing based on geographic location:

  1. Set the zone's geographic location:

    ALTER SYSTEM MODIFY ZONE "zone5" SET REGION="SHANGHAI", IDC="idc5";  
    
  2. Bind the LDC information of ODP:

    Method 1: Specify the LDC information by using the -o parameter when the ODP process starts:

    ./obproxy -o proxy_idc_name=idc5  
    

    Method 2: Set the LDC information by executing an SQL statement:

    obclient> alter proxyconfig set proxy_idc_name='idc1';
    

References

  • For more information about routing policies of OceanBase Database, see OceanBase Database Proxy (ODP).

  • For more information about common routing features and their configurations of ODP, and how to configure routing policies and troubleshoot routing issues in business scenarios, see ODP routing best practices.

Next topic

Best practices for read-write splitting
Next
What is on this page
Background information and objectives
Configuration methods
Method 1: Configure columnstore replicas (core method for AP acceleration)
Method 2: Enable weak-consistency read (prerequisites for routing AP requests)
Method 3: Configure resource isolation for large queries
Typical configuration examples
Example 1: Dedicated routing for columnstore replicas
Example 2: Proximity-based routing for AP requests across data centers
Appendix 1: Description of key parameters
Appendix 2: ODP routing policies and LDC basics
Random routing policy
LDC configuration (optional)
References