Architecture of a database cluster group for Aurora
A database cluster group for Aurora consists of the group and its member clusters. The group runs coordinated operations, group backup and point-in-time restore, and monitoring across its member clusters. If you enable routing, the group has a routing layer behind one routing endpoint. If you move data, managed data movement runs between member clusters. The following diagram shows a group with routing enabled.
Components of a database cluster group for Aurora
A database cluster group for Aurora is an Amazon RDS resource that holds Aurora DB clusters and runs operations across them. It has its own Amazon Resource Name (ARN) in the format arn:aws:rds:region:account-id:cluster-group:resource-id. You create and manage a database cluster group with the Amazon RDS API, the AWS CLI, and the AWS SDKs, and IAM policies name it by its ARN, as they name a DB cluster. A database cluster group holds member clusters from one AWS account and one AWS Region.
A database cluster group for Aurora has its own maintenance window, backup window, backup retention period, deletion protection, and routing settings. These settings apply to group operations, not to each member cluster. The group backup window can't overlap the maintenance window of the group or of any member cluster, and the group backup retention period can't be longer than the backup retention period of any member cluster. For more information, see Creating, modifying, and deleting a database cluster group for Aurora.
A database cluster group for Aurora has the following components:
-
Member clusters hold your data.
-
The routing layer sends each request from the routing endpoint to the member cluster that holds its data. The routing layer runs only when you enable routing.
-
Managed data movement moves data between member clusters.
Member clusters
A member cluster stays a standard Aurora DB cluster. It has its own writer, readers, failover, parameter group, backups, and endpoints. Both provisioned and Aurora Serverless v2 DB instances can run in a member cluster. Adding a cluster to a group copies no data and doesn't change its endpoints. Before you remove a member cluster that runs Aurora MySQL version 8.4.900, delete its DB instances. The removed cluster keeps its data and endpoints, but you can't create DB instances in it while it isn't in a database cluster group for Aurora. For more information about how Aurora DB clusters work, see Amazon Aurora DB clusters.
You can't add a DB cluster that uses a burstable-performance DB instance class (db.t*) to a database cluster group for Aurora.
A member cluster doesn't depend on the other member clusters. An Amazon RDS API call on the cluster, or a statement on a direct connection to it, acts on that member cluster only. Data mappings name a member cluster by its member cluster alias, so renaming a member cluster doesn't change the data mappings that place objects on it.
While a cluster is a member, the following changes apply:
-
Routed statements run on its writer only.
-
Its own automatic minor version upgrade setting doesn't apply. You upgrade it with the group.
-
It can't be part of an Aurora global database.
Removing a member cluster doesn't check data mappings. Before you remove a member cluster, either move the collocations of the outgoing member cluster to another member cluster or delete the related data mappings. After you remove the member cluster, any attempt to reach that member cluster through stale data mappings returns an error. For the procedures to add and remove member clusters, see Adding and removing member clusters.
An existing cluster joins a group when you add it with add-db-cluster-to-db-cluster-group. On Aurora MySQL version 8.4.900, you can create DB instances only in a DB cluster that belongs to a database cluster group for Aurora. To add a cluster, create it without DB instances, add it to the group, and then create its DB instances after it joins. Adding a cluster copies no data and doesn't change its endpoints.
Because the cluster has no DB instances when it joins, the add restarts nothing, replaces nothing, and drops no connections. To bring an existing Aurora MySQL 8.4 cluster, restore a snapshot of it onto version 8.4.900, and then add the restored cluster. A restore onto 8.4.900 from an earlier major version, such as Aurora MySQL version 3, isn't supported.
For the procedures, see Add member clusters.
A cluster keeps its own DB cluster parameter group, and the group doesn't change it. When a cluster joins, Aurora sets internal engine settings that routing and data movement need on each DB instance of the cluster. These settings aren't in the parameter group, and you don't manage them. The group doesn't align parameter groups, and the routing layer doesn't compare parameter values between member clusters. Through the routing endpoint, the routing layer sets sql_mode, time_zone, and the other variables in the starting values table in Session variables the routing layer holds and forwards on every member session. Keep the other parameters that affect how a statement is interpreted, such as div_precision_increment, the same on every member cluster. To change a value, modify the DB cluster parameter group of each member cluster, and reboot the cluster when the parameter is static. For more information, see Parameter groups for Amazon Aurora.
A session-level SET through the routing endpoint applies on each member cluster that the session reaches. The session sees one value, even when the parameter groups differ. On Aurora MySQL, session-level transaction settings are the exception. For the rules, see Transaction rules on Aurora MySQL.
Routing layer and routing endpoint
When you enable routing, a database cluster group for Aurora has a routing layer behind one routing endpoint. AWS manages the routing layer and scales it with your workload, so you size only your member clusters. For connections through the routing endpoint, see Managing connections. The routing layer holds no table data, so a failure in the routing layer loses none of your data. Your data mappings and scaleout table definitions belong to the group, and you read them through the group's system tables at the routing endpoint.
You configure the routing layer on the group with the --routing-endpoint-configuration option of the create, modify, and restore operations. describe-db-cluster-groups returns its settings in RoutingEndpointConfigurationInfo. The routing layer doesn't run initialization statements. On Aurora MySQL, it sets sql_mode, time_zone, autocommit, transaction_isolation, and some timeouts on each session from its own defaults or, for the first four, from the routing endpoint parameters. It sets the connection character set variables from the utf8mb4 collation that the client sends when it connects, and uses utf8mb4 when the client sends none. The routing layer accepts only the utf8mb4 character set at connect, and refuses a client that asks for another character set, such as latin1, with error 1115. Set any other values that your application needs when it connects. For more information, see Configuring the routing endpoint.
The routing endpoint is a writer endpoint. It sends traffic to the writer of each member cluster, not to its readers. AWS provisions the routing endpoint in the VPC subnets that you choose when you enable routing, and the endpoint isn't publicly accessible. It exists only in the Availability Zones of those subnets, and you can't change the subnets after you enable routing. The service generates the endpoint name from the group identifier and the DNS identifier of your account, so read the name from the output of describe-db-cluster-groups instead of building it, for example before you scope an egress allowlist or a VPC endpoint policy. For more information, see Connectivity within a VPC.
When any member cluster is Multi-AZ, the routing layer runs in more than one Availability Zone. If the writer of a member cluster fails over or restarts, the routing layer closes the sessions routed to it, and their open transactions roll back, so reconnect and retry the transaction. Statements routed to other member clusters continue.
At preview, the routing layer and routing endpoint have the following limitations:
-
A reader endpoint isn't available. The
ReaderEndpointvalue that the API returns for a database cluster group for Aurora reaches the writers of the member clusters and accepts writes. To send read-only traffic to Aurora Replicas, use the reader endpoint of each member cluster. For more information, see Amazon Aurora endpoint connections. -
The routing layer doesn't isolate a failed Availability Zone automatically, so some new connections can reach the failed zone and time out. Retry connections with a timeout, and the retry reaches a healthy Availability Zone.
The routing layer authenticates each connection as a router user, who signs in with a password. The routing layer enforces the group privileges, then reaches each member cluster as the member cluster user of the same name. A router user isn't copied to the member clusters, so create a matching member cluster user over a direct connection on each member cluster that the router user must reach. Without that user, the router user can't reach or pin to the member cluster. The routing layer connects to member clusters with mutual TLS, using AWS-managed certificates. For more information, see Router users and routing layer privileges.
The routing endpoint requires TLS 1.2 or TLS 1.3 and refuses a connection without TLS. On Aurora MySQL, the refused connection gets error 3159 after the credential and account-lock checks. Set each client to use TLS. You can't turn off the TLS requirement or change the minimum TLS version. For client TLS settings, see Encryption in transit (TLS) and at rest.
Enabling routing doesn't send any existing connection through the routing layer. An application uses the routing layer only when you point its connection string at the routing endpoint, and direct connections to each member cluster stay available. Both paths reach the same rows, so decide which path each application uses to write each table. A direct connection signs in as a member cluster user, while a router user is an account at the routing endpoint only.
Data movement
Managed data movement moves data between member clusters with minimal downtime, while your applications keep using the same routing endpoint and the same SQL. AWS operates it on its own compute, separate from the routing layer and from your member clusters. A data movement job copies the data to the target member cluster, keeps the copy in step with changes on the source member cluster, and then switches routing to the target. You decide what moves and when, and Aurora doesn't move data on its own. The following rules shape a move:
-
The unit of movement is the collocation. A job moves a whole collocation, with every database and table that its data mappings name. A job can't divide a collocation.
-
A job moves one collocation to another member cluster. For example, a job can move a collocation onto a new member cluster, off a busy member cluster, or off a member cluster that you plan to remove.
-
Writes pause briefly when routing switches to the target. A write that reaches the moving objects at that moment gets a retryable error. For the error codes, see Moving data between member clusters.
You start a job with ALTER DBCLUSTERGROUP MOVE COLLOCATION at the routing endpoint. For the syntax, see ALTER DBCLUSTERGROUP MOVE COLLOCATION. Because a job moves a whole collocation, the number of collocations that you create decides how finely you can spread data later, so plan your collocations before you load data. For the procedures, see Moving data between member clusters and Rebalancing member clusters.
At preview, a database cluster group for Aurora runs one data movement job at a time. Start the next job after the current job completes or after you cancel it.
How routing works
Through the routing endpoint, each routed statement and each transaction runs on exactly one member cluster, and separate transactions in one session can each run on a different member cluster. The member cluster depends on what you declared for the object, not on how you wrote the statement:
-
Database-level mappings. A data mapping places a whole database on one member cluster. Every statement on that database goes to that member cluster.
-
Table-level mappings. A data mapping places one table on one member cluster. Every statement on that table goes to that member cluster.
-
Scaleout tables and routing functions. The routing layer reads the routing key value in the statement. The routing function maps that value to a collocation, and the member cluster that holds that collocation runs the statement.
The routing layer serves only a statement or a transaction that resolves to exactly one member cluster. If a statement or a transaction spans more than one member cluster, the routing layer returns an error. To work across member clusters, keep the related data in one collocation so that it stays on the same member cluster, or divide the query into several smaller queries.
A query reaches a member cluster in one of the following ways. A session on the routing endpoint can switch between query routing mode and a pinned session without reconnecting.
-
Query routing mode, the default. Each statement goes to the member cluster that holds the objects that it names.
-
A pinned session. You bind the session to one member cluster, and the routing layer passes every statement through. Anything that the member cluster accepts runs there, including DDL, administrative statements, and catalog reads. A pinned session names objects by their cluster names. Any router user can pin a session. Pinning needs no privilege. Run statements on the group's system tables and
SCALEOUTstatements in query routing mode. -
A direct connection to a member cluster endpoint, without the routing layer.
A transaction through the routing endpoint binds to the member cluster of its first routed statement until it ends. For the rules, see Sessions, transactions, and session pinning. Data mapping changes aren't transactional, so issue each change outside a transaction. For when a data mapping change reaches the routing layer, see Applying data mapping changes. That section also covers what a statement routed on an older mapping gets.
The routing layer directs each statement by its data mappings. It doesn't inspect your schema. The group reads data on member clusters without validating it. An object that no data mapping or scaleout table declares isn't reachable through query routing. Reach it through a direct connection or a pinned session. Create your data mappings before an application uses the routing endpoint, or use a pinned session or a direct connection until then.
You keep control of the objects on each member cluster. The routing layer doesn't check that a mapped object exists on its member cluster. It accepts a data mapping for a table that you haven't created, and the first statement that uses the table fails. Create the object on the member cluster, then map it. A permission, read-only, or constraint error on your data comes from the member cluster when the statement runs, not when you connect.
A routed statement runs on the writer of its member cluster, so a read sees every write committed on that member cluster. Within a member cluster, primary keys, unique constraints, check constraints, and indexes work as on a standalone Aurora DB cluster. No index or constraint spans member clusters.
The following examples show a statement for each kind of declaration.
For more information, see Data mappings and collocations and Scaleout tables and routing functions.
Key terms
This chapter uses the following terms.
- Database cluster group for Aurora
-
The resource that binds a set of Aurora DB clusters and, when routing is enabled, the routing layer that serves them. It has its own Amazon Resource Name (ARN), settings, and group operations. All member clusters of a group are in one AWS account and one AWS Region. For more information, see Architecture of a database cluster group for Aurora.
- Member cluster
-
A standard Aurora DB cluster in a group, with its own writer, readers, failover, parameter group, backups, and endpoints. It stays directly reachable through those endpoints. With routing, it holds the part of your data that you place on it. Before you remove a member cluster that runs Aurora MySQL version 8.4.900, delete its DB instances. The removed cluster keeps its data and endpoints, but you can't create DB instances in it while it isn't in a database cluster group for Aurora.
- Member cluster alias
-
The name of a member cluster at the routing endpoint. Data mappings, session pins, and data moves name a member cluster by this alias, which you read from the
dbclustergroup_sys.member_cluster_mappingssystem table. Don't derive it from a cluster identifier. - Routing layer
-
The component behind the routing endpoint that directs requests to member clusters. AWS manages it, and it scales automatically with your workload. It authenticates router users, sends each routed statement to one member cluster, and answers some statements itself. It holds no table data.
- Routing endpoint
-
The single read-write endpoint of a group with routing enabled. Applications that you choose connect to it. For more information, see Connecting to the routing endpoint.
- Data mapping
-
A row in the
dbclustergroup_sys.data_mappingssystem table that places a database or a table on one member cluster. It gives the object a router name and names its collocation. For more information, see Data mappings and collocations. - Router name and cluster name
-
The router name is the name that your application uses for a database, a schema, or a table through the routing endpoint. The cluster name is the name of the object on the member cluster that holds it. A cluster name names an object; it isn't the DB cluster identifier or the member cluster alias.
- Collocation
-
A named group of data mappings that stay on the same member cluster and move between member clusters together. It's the unit of data movement. A mapping that names no collocation takes the member cluster alias as its collocation.
- Scaleout table
-
One logical table whose rows are spread across several member clusters. You query it by one name, and the routing layer uses its routing key and routing function to find the member cluster for each row. For more information, see Scaleout tables and routing functions.
- Member table
-
One table of a scaleout table, on one member cluster. Each member table holds the rows of one collocation.
- Routing key
-
The column, or columns, whose value decides which member cluster holds a row of a scaleout table.
- Routing function
-
The rule that maps a routing key value to a collocation: the Aurora-provided
MOD,HASH,PREFIX, orCOLUMNfunction. A data mapping assigns each collocation to a member cluster. For more information, see Routing functions. - Router user
-
The account that a client signs in as at the routing endpoint. The routing layer checks the login and the group privileges, such as
dbclustergroup_metadata_adminfor changing data mappings anddbclustergroup_user_adminfor managing router users. You grant group privileges only to router users. A router user isn't copied to the member clusters. For more information, see Router users and routing layer privileges. - Member cluster user
-
The account on a member cluster with the same name as a router user. Routed and pinned sessions run as this user, and the member cluster checks its data privileges.
- Connection mode
-
The way that the routing endpoint treats the statements of a connection: query routing mode or a pinned session. A connection has one mode at a time, and the SQL that you can run depends on the mode. A direct connection to a member cluster isn't a connection mode but a separate path. For more information, see Connection options.
- Query routing mode
-
The default mode of a connection to the routing endpoint. The routing layer sends each statement to the member cluster that holds the objects that it names, by router name. It answers some statements itself, such as the session
SETstatements that it holds and reads of the group's system tables. - Session pin (pinned session)
-
A session on the routing endpoint that you bind to one member cluster with
SET SESSION router_cluster_pin. The routing layer passes every statement of a pinned session through to that member cluster, which runs any statement that it accepts, including DDL, administrative statements, and catalog reads. A pinned session names objects by their cluster names, and it names the member tables of a scaleout table, not the scaleout table. Any router user can pin a session. For more information, see Session pinning. - Direct connection
-
A connection to the endpoint of a member cluster instead of the routing endpoint. It uses cluster names, accepts the full SQL of the engine, and doesn't go through the routing layer. Direct connections and the routing endpoint are both supported ways to connect, at any time.
- Transaction binding
-
Inside a transaction, the first routed statement binds the transaction to its member cluster until
COMMITorROLLBACK. This binding isn't a session pin, and you keep naming objects by router name. - Data movement
-
The managed capability that moves one collocation from one member cluster to another, with minimal downtime, while your applications keep using the same routing endpoint. At the end of a move, reads and writes to the moving objects pause briefly while routing switches to the destination member cluster. A read or write in that pause gets a retryable error. For more information, see Moving data between member clusters.
- Stale mapping error
-
The retryable error that a statement gets when the routing layer routed it on an older data mapping. Outside a transaction, Aurora MySQL returns error 1412, and a retry of the statement routes on the new mapping. Inside a transaction, a statement that needs a mapping changed after the transaction's first routed statement fails with error 63928, and the routing layer has already rolled the transaction back, so retry the whole transaction. For more information, see Transaction errors and retries.