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

What Is Database Proxy?

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

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

Read/write splitting means that read and write requests are automatically forwarded through database proxy addresses. After creating a TaurusDB instance, you can create a proxy instance. With the proxy address, write requests are automatically forwarded to the primary node and read requests are forwarded to each node based on the routing policy of the proxy instance, offloading the read pressure from the primary node.

Introduction Video

Basic Concepts

  • Proxy address

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

  • Proxy mode

    There are read/write and read-only proxy modes.

    Read/Write: All write requests are routed only to the primary node, and all read requests are routed to the selected nodes based on the read weights or active connections.

    Read-only: All read requests are routed to the selected read replicas based on the read weights or active connections. The read requests will not be routed to the primary node.

  • Transaction splitting

    With transaction splitting enabled for a proxy instance, the proxy instance can route read requests prior to write operations in a transaction to read replicas, reducing the load on the primary node.

    For more information about transaction splitting, see Enabling Transaction Splitting for a Proxy Instance.

  • Connection pool

    Proxy instances provide session-level connection pools, which help reduce the database load caused by frequent establishment of short connections.

    For more information about connection pools, see Enabling the Connection Pool for a Proxy Instance.

  • Routing policy

    Proxy instances support weighted and load balancing routing policies.

    • Weighted: Read requests are assigned to nodes based on the weights you specify.
    • Load balancing: Read requests are assigned to nodes with fewer active connections. In the load balancing policy, you do not need to configure the weights of nodes.

    For more information about routing policies, see Modifying the Routing Policy of a Proxy Instance.

How Read/Write Splitting Works

You can create one or more proxy instances for your TaurusDB instance to enable read/write splitting.

  • Single proxy instance

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

    Figure 1 Read/write splitting with only one proxy instance
  • Multiple proxy instances

    To isolate workloads from one another, you can create up to four proxy instances for a TaurusDB instance. Different applications can connect to different proxy instances as required. The associated read replicas of the proxy instances process read requests from different applications for workload isolation.

    Figure 2 Read/write splitting with multiple proxy instances

Application Scenarios

  • The primary node is overloaded due to a large number of requests in a transaction.
  • The primary node is overloaded due to excessive connections.
  • Read/write splitting is required.

Read/Write Splitting Advantages

  • Compared with manual read/write splitting in applications, the read/write splitting using proxy addresses features flexible scale-out and 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 instance routes read requests of an application only to its associated read replicas to isolate workloads.
  • By default, proxy instances provide overload protection to prevent server OOM (out of memory) due to heavy pressure when you perform operations on large result sets. This function is enabled by default and does not need to be configured separately. The pressure caused by the slow kernel depends on flow control.

Request Routing Rules

  • Write requests sent only to the primary node
    • INSERT, UPDATE, and DELETE
    • 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 Enabling Transaction Splitting for a Proxy Instance.)
    • User-defined functions
    • Stored procedures
    • EXECUTE statements
    • Multi-statement requests
    • Requests that use temporary tables
    • All changes to user variables
    • KILL in SQL statements (not command KILL)
  • Read requests sent only to the primary node
    • If query statements are in transactions, the transaction requests are routed to the primary node. If SET AUTOCOMMIT=0 is added before a query statement, the transaction requests are routed to the primary node.
    • If all read replicas are abnormal or the read weights allocated to the read replicas are 0, requests will be routed to the primary node. You can set read weights for the primary node and read replicas after read/write splitting is enabled.
    • When running SQL statements:
      • If multi-statements (for example, insert xxx;select xxx) are executed, all subsequent requests will be routed to the primary node. To restore read/write splitting, disconnect your application from your instance and then connect it back again.
      • Read operations with locks (for example, SELECT for UPDATE) will be routed to the primary node.
      • When /*FORCE_MASTER*/ is used, requests will be routed to the primary node.
      • If the HANDLER statement is executed, all subsequent requests will be routed to the primary node. To restore read/write splitting, disconnect your application from your instance and then connect it back again.
    • SELECT last_insert_id()
    • All queries of user variables
  • Requests sent either to the primary node or a read replica
    • SELECT not in a transaction
    • The COM_STMT_EXECUTE command
  • Requests always sent to all nodes
    • Changes to all system variables
    • The USE command

Read/Write Attribute Processing Logic

There are read-only and read/write modes for proxy instances. The read/write attribute processing logic varies depending on the proxy mode.

Proxy Mode

Routing Policy

Weight of Primary Node

Normal Case

All Read Replicas Are Faulty

Read-only

Weighted

Load balancing

Not configurable

The primary node does not process read-only requests.

Proxy address: readable but not writable

The primary node does not process read-only requests.

Proxy address: connection error

Read/Write

Load balancing

Assigned by system

Primary node: readable and writable

Proxy address: readable and writable

Primary node: readable and writable

Proxy address: readable and writable

Weighted

> 0

Primary node: readable and writable

Proxy address: readable and writable

Primary node: readable and writable

Proxy address: readable and writable

= 0

Primary node: not readable but writable

Proxy address: readable and writable

Primary node: readable and writable

Proxy address: readable and writable

Billing

Proxy instances are free.

Precautions

Table 1 Precautions for proxy instances

Category

Precaution

Version constraints

  • If the kernel version of your TaurusDB instance is one of the following, proxy instances cannot be created:
    • From 2.0.26.2 to 2.0.28.3
    • 2.0.29.1
  • If the kernel version of your TaurusDB instance is earlier than 2.0.42.230601, only one proxy instance can be created.
  • If the kernel version of your TaurusDB instance is 2.0.42.230601 or later, up to four proxy instances can be created.

For details about how to check the kernel version, see How Can I Check the Version of a TaurusDB Instance?

Unsupported functions

  • Proxy instances do not support compression protocols.
  • Proxy instances do not support the READ-UNCOMMITTED transaction isolation level.
  • Proxy instances do not support reads from and writes to any column containing more than 16 MB of data in a table.
  • Database proxies do not support the SQL mode parameter PAD_CHAR_TO_FULL_LENGTH.

Usage constraints

  • To create a proxy instance, the TaurusDB instance must have at least 8 vCPUs.
  • Read/write splitting can be enabled only when at least one read replica is created.
  • After read/write splitting is enabled, the database port and private IP address of your TaurusDB instance cannot be changed.
  • If multi-statements are executed, all subsequent requests will be routed to the primary node. To restore the read/write splitting function, disconnect the connection from your applications and establish a connection again.
  • When a proxy address is used, all transaction requests are routed to the primary node (you can use transaction splitting to route read requests prior to write operations in a transaction to read replicas). The non-transaction read consistency is not ensured. To ensure read consistency, encapsulate the read requests into a transaction.
  • When a proxy address is used, you can run show processlist command on the proxy instance or TaurusDB instance. If show processlist is executed on a proxy instance, only the services delivered through proxy nodes are displayed.
  • If a proxy node is abnormal, running show processlist or Kill on the proxy instance may take a long time, but services are not affected.
  • After a proxy node is deleted, services on the deleted proxy node may be displayed when show processlist is executed on the proxy instance.
  • If Kill is executed on the proxy instance, error information such as timeout may be displayed occasionally. You can run show processlist again to check whether the services are killed successfully.
  • If a proxy node is abnormal, there may be frame freezing for 2 seconds when you run show processlist on the proxy instance. The results will still be returned.
  • When a proxy instance is used, the size of a concatenate SQL statement cannot exceed 100 MB to prevent statement parsing from consuming too many resources.

HTAP analysis

  • Consistency levels and connection pools are not supported.
  • Only the weighted routing policy is supported.
  • Only the read/write proxy mode is supported.

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