Updated on 2026-01-16 GMT+08:00

Introduction to Database Proxy

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

Read/Write splitting enables read and write requests to be automatically routed through a proxy address. After creating a TaurusDB for PostgreSQL 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 load from the primary node.

Proxy instances are free.

Basic Concepts

How Read/Write Splitting Works

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

If your TaurusDB for PostgreSQL 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

To isolate workloads from one another, you can create up to four proxy instances for a TaurusDB for PostgreSQL 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

Read/Write Splitting Advantages

  • Read/Write splitting enables read and write requests to be automatically routed. You can easily scale out a proxy instance as required at low maintenance costs.
  • Read requests are distributed to read replicas to balance database traffic and improve resource utilization.
  • A proxy instance routes read requests of an application only to its associated read replicas to isolate workloads.

Request Routing Rules

Precautions

Table 2 Precautions for proxy instances

Category

Precaution

Unsupported functions

You cannot control access by editing the database's pg_hba file, and blocking proxy IP addresses there will prevent the proxy instances from connecting to the database.

Usage constraints

  • 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 for PostgreSQL instance cannot be changed.
  • If multiple proxy instances are deployed or users directly log in to the database, operations such as creating users, changing passwords, and changing permissions may not be applied immediately. The SQL statements of these operations will apply within the delay specified by the cache_refresh parameter, which defaults to 5 minutes.
    NOTE:

    cache_refresh specifies the interval (in seconds) for reading user and database metadata from the database and refreshing the cache. The default value is 300 seconds (5 minutes). You can manually change the value.

  • The lastval() and currval() functions may fail to obtain related values and can only be used in transactions.
  • rdsAdmin is the built-in account of the database proxy system. You are advised not to create an account with the same name or modify this account, or read/write splitting may not work properly.
  • The statements for modifying database parameters (including ALTER SYSTEM SET and SELECT pg_reload_conf()) are only applied on the primary node.
  • If a transaction is started, the entire transaction is executed on the primary node. (If a transaction is explicitly declared as read-only, the entire transaction is executed on a read replica.)
  • SQL statements that invoke stored procedures or use common table expressions are routed to the primary node.
  • When a proxy instance is used, database names and all database object names (including database names, table names, schemas, index names, and usernames) only support printable ASCII characters.
  • You cannot log in to the database as user rdsAdmin, rdsBackup, rdsMetric, or rdsRepl through a proxy instance.
  • You cannot log in to database template0 or template1 through a proxy instance.