Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Situation Awareness
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive

Configuring the Delay Threshold and Routing Policy

Updated on 2024-10-14 GMT+08:00

After read/write splitting is enabled and read replicas are created, you can configure the delay threshold and routing policy as required.

Table 1 Read/write splitting parameters

Parameter

Description

Delay Threshold

The maximum delay for data to be synchronized from primary DB instances to read replicas. This parameter is only applied when there are read replicas. To prevent data inconsistencies between primary DB instances and read replicas from lasting too long, if the delay of a read replica exceeds the configured threshold, read requests are not forwarded to the read replica regardless of the read weight distributed to it.

When read/write splitting is enabled, the default delay threshold is 30s and the default value range is 0–7,200s. It is recommended that the threshold be greater than or equal to 30s. Traffic is not allocated to read replicas whose delay exceeds the configured threshold.

Read Weight Distribution

After read/write splitting is enabled, you can configure read weights for the primary DB instance and read replicas. If no read replicas are selected for the database proxy, read/write splitting cannot be used.

The read weight ranges from 1 to 1,000. Read replicas with higher read weight distributions process more read requests. For example, if the read weights distributed to one primary DB instance and four read replicas are 0, 100, 200, 500, and 300, respectively, the primary DB instance does not process any read requests (write requests are still automatically routed to the primary DB instance) while the four read replicas process read requests with a ratio of 1:2:5:3.

Constraints

To enable proxy load balancing, contact customer service.

All proxies of your DB instance must be in the Available state.

Configuring Delay Threshold

  1. Log in to the management console.
  2. Click in the upper left corner and select a region.
  3. Click in the upper left corner of the page and choose Databases > Relational Database Service.
  4. On the Instances page, click the primary instance name.
  5. In the navigation pane on the left, click Database Proxy.
  6. In the proxy information area, click next to the Delay Threshold field.

Configuring Routing Policy in Single-Proxy Mode

  1. Log in to the management console.
  2. Click in the upper left corner and select a region.
  3. Click in the upper left corner of the page and choose Databases > Relational Database Service.
  4. On the Instances page, click the primary instance name.
  5. In the navigation pane on the left, click Database Proxy.
  6. If proxy load balancing is not enabled, click Configure next to the Routing Policy field in the proxy information area. In the displayed dialog box, configure read weights for the primary instance and read replicas.

    NOTE:
    • The system automatically distributes weights to read replicas, including read replicas created afterwards, according to the default distribution rules. If a read replica breaks down or is deleted, the weight is automatically removed. After the read replica recovers, the weight is automatically restored.
    • If the weight of a node is set to 0, read requests will not be routed to the node. If the weights of all nodes are set to 0, read requests will be randomly routed to these nodes.
    • Forcible routing is also supported. For details, see Adding a Hint to Specify the Direction that a SQL Statement Will Be Routed.
    Figure 1 Setting read weight

  7. Click OK and view the weights on the Database Proxy page.
  8. If proxy load balancing is enabled, click Configure next to the Routing Policy field in the proxy information area. In the displayed dialog box, set required parameters.

    Select Load balancing as the routing policy. Read requests will be automatically distributed to read replicas based on the number of active connections to balance the load among these read replicas.

    Figure 2 Routing policy - Load balancing
    Read Requests Accepted by Primary DB Instance:
    • Yes: Read requests can be routed to both the primary instance and read replicas, which increases the load of the primary instance. Configure this parameter as required.
    • No: To offload read pressure from the primary instance, read requests are only routed to read replicas.

  9. Click OK. On the Database Proxy page, view the result. You can select the instances for load balancing as required.

Configuring Routing Policy in Multi-Proxy Mode

  1. Log in to the management console.
  2. Click in the upper left corner and select a region.
  3. Click in the upper left corner of the page and choose Databases > Relational Database Service.
  4. On the Instances page, click the primary instance name.
  5. In the navigation pane on the left, click Database Proxy.
  6. In the proxy information area, click Configure next to the Routing Policy field. In the displayed dialog box, set required parameters.

    • Weighted: You can distribute read weights for the DB instance and read replicas. For details, see Table 1.
      NOTE:

      The system automatically distributes weights to read replicas, including read replicas created afterwards, according to the default distribution rules. If a read replica breaks down or is deleted, the weight is automatically removed. After the read replica recovers, the weight is automatically restored.

      Forcible routing is also supported. For details, see Adding a Hint to Specify the Direction that a SQL Statement Will Be Routed.

      Figure 3 Weighted
      Click OK and view the weights in the proxy information area.
      Figure 4 Viewing weights
    • Load balancing: If selected, to balance the load among read replicas, read requests are automatically distributed to multiple read replicas based on the number of active connections.
      Figure 5 Load balancing

      In the Select DB Instance drop-down list, select the instances for load balancing.

      NOTE:

      To add new read replicas for load balancing, select the read replicas from the Select DB Instance drop-down list and click OK.

      Click OK and view DB instances for load balancing in the proxy information area.
      Figure 6 Viewing DB instances for load balancing

Adding a Hint to Specify the Direction that a SQL Statement Will Be Routed

Hints supported by read/write splitting are as follows:

  • /*FORCE_MASTER*/: A SQL statement is routed to the primary DB instance.
  • /*FORCE_SLAVE*/: A SQL statement is routed to a read replica.
NOTE:
  • In addition to the weight distribution system of read/write splitting, hints are a useful type of SQL syntax that allows you to specify whether a SQL statement is executed on the primary DB instance or on a read replica.
  • Hints are only used as routing suggestions. In non-read-only SQL and non-transaction scenarios, SQL statements cannot be routed to read replicas.

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback