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

Introduction to RDS for MySQL Database Proxy

Updated on 2025-01-02 GMT+08:00

Database Proxy is a network proxy service that sits between RDS for MySQL and applications. It is used to handle all requests from the applications to access RDS for MySQL instances.

Read/write splitting enables read and write requests to be automatically routed through a database proxy address. After creating an RDS for MySQL instance, you can enable database proxy. Through the proxy address, write requests are routed to the primary instance and read requests to read replicas based on the routing policy of the proxy, reducing the read pressure of the primary instance.

Basic Concepts

  • Proxy address

    After purchasing a database proxy, you can view the proxy address on the Database Proxy page. The database proxy sends write requests to the primary instance and read requests to read replicas through this address.

  • Transaction splitting

    Database proxies support transaction splitting. With this feature enabled, the read requests prior to write operations in a transaction are routed to read replicas, offloading read pressure from the primary instance.

    For more information about transaction splitting, see Configuring Transaction Splitting.

  • Connection pool

    Database proxies provide session-level connection pooling. It helps reduce the database load caused by frequently setting up short connections.

    For more information about connection pools, see Configuring Connection Pools.

  • Routing policy

    RDS for MySQL database proxies support weighted and load balancing routing policies.

    • Weighted: Read requests are routed based on the read weights you specify.
    • Load balancing: Read requests are routed to database nodes with fewer active connections. With this policy enabled, you do not need to configure the weights of nodes.

    For more information about routing policies, see Configuring the Delay Threshold and Routing Policy.

How Read/Write Splitting Works

Read/write splitting uses database proxies to split read and write requests. You can create one or more database proxies for your DB instance.

  • Single database proxy

    If your RDS for MySQL instance has only one database proxy, applications connect to the database proxy through the proxy address. Write requests are forwarded to the primary instance and read requests to the primary instance or read replicas based on the routing policy you specify.

    Figure 1 Read/write splitting with only one database proxy
  • Multiple database proxies

    To isolate workloads from one another, you can create up to four database proxies for an RDS for MySQL instance. Different applications can connect to different database proxies as required. The database proxies connect to specified read replicas and forward read requests from different applications to different read replicas for workload isolation.

    Figure 2 Read/write splitting with multiple database proxies

Scenario

  • Read/write splitting enables read and write requests to be automatically routed. If your application requires more proxies, you can request additional proxy nodes with just a few clicks.
  • Read requests are distributed to your read replicas based on weights to balance your database traffic and improve resource utilization.
  • A proxy routes read requests of your application only to the read replicas you specify for the proxy.

Advantages of Read/Write Splitting

  • Read/write splitting enables read and write requests to be automatically routed. You can easily scale out a database proxy as required at low maintenance costs.
  • Read requests are distributed to your read replicas based on weights to balance your database traffic and improve resource utilization.
  • A proxy routes read requests of your application only to the read replicas you specify for the proxy.
  • By default, database proxies provide overload protection to prevent operations with large result sets from causing out of memory (OOM) exceptions of the server. If the database kernel pressure is high, database traffic throttling is required.

Request Routing Rules

  • The following requests will be routed only to the primary instance.
    • INSERT, UPDATE, DELETE, and SELECT FOR UPDATE
    • All DDL operations (such as table/database creation, table/database deletion, table structure change, and permission change)
    • All requests in transactions (But if transaction splitting is enabled, some read requests in transactions may be sent to read replicas. For details, see Configuring Transaction Splitting.)
    • User-defined functions
    • Stored procedures
    • Multi-statement requests
    • Requests that use temporary tables
    • SELECT last_insert_id()
    • All queries of and changes to user variables
  • The following requests will be routed either to the primary instance or a read replica.
    • SELECT not in a transaction
    • COM_STMT_EXECUTE
  • The following requests will always be routed to all database nodes.
    • Changes to all system variables
    • The USE command

Read/Write Role Processing Logic for Database Proxy

Role

Routing Policy

Weight of Primary Instance

Normal Case

All Read Replicas Are Faulty

Read only

Weighted

Load balancing

Not configurable

Primary instance: does not process read-only requests.

Proxy address: readable but not writable

Primary instance: does not process read-only requests.

Proxy address: connection error

Read and write

Load balancing

Assigned by system

Primary instance: readable and writable

Proxy address: readable and writable

Primary instance: readable and writable

Proxy address: readable and writable

Weighted

> 0

Primary instance: readable and writable

Proxy address: readable and writable

Primary instance: readable and writable

Proxy address: readable and writable

= 0

Primary instance: not readable but writable

Proxy address: readable and writable

Primary instance: readable and writable

Proxy address: readable and writable

Billing

Database proxy can be enabled only for purchased DB instances. After it is enabled, it is separately billed on a pay-per-use basis.

The database proxy service is available for commercial use. It is billed by node. When you purchase a database proxy instance on the console, two nodes are created by default. The total fee is calculated as follows: Total fee = Number of nodes x Unit price. For details about the unit price, see the price of database proxy in RDS Pricing Details.

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