Rebalancing member clusters
In a database cluster group for Aurora, rebalancing means moving whole collocations, one at a time, to other member clusters. You rebalance to relieve a busy member cluster, to put data on a new member cluster, or to empty one that you plan to remove. You decide when to rebalance, and each move uses managed data movement.
You manage the capacity of each member cluster. A member cluster stays a standard Aurora DB cluster, so its instance class, instance count, and readers stay under your control. AWS manages the routing layer and scales it automatically.
What a rebalance can move
A rebalance moves whole collocations. When you plan, keep the following in mind:
-
A move can't split one collocation, one bucket of a routing function, or one routing key value.
-
If every object on a member cluster shares its default collocation, moving that collocation moves all of the member cluster's data.
-
A statement that reaches two collocations on one member cluster fails after a move separates them. Change the statement before the move.
-
A scaleout table spreads onto more member clusters only if it has more collocations than member clusters.
-
A move doesn't fix load that data placement doesn't cause, such as a single busy instance or a batch job connected directly to one member cluster.
Deciding what to move
To rebalance member clusters
-
At the routing endpoint, read
dbclustergroup_sys.data_mappings, and build a placement table (member cluster, collocations, objects) in your client. Add each collocation's size and statement time from the reads in Identifying hot member clusters. -
Decide what to move. If a member cluster's load is spread over several collocations, move some of them. If the load sits in one collocation or one key value, move its neighbors off instead. Prefer the smallest collocations that meet the goal, because they copy faster.
-
Write the plan as a before-and-after placement table, one move for each collocation. Check each collocation's workload for statements that reach another collocation.
-
Run each move as described in Moving a collocation. Start the next move only after
move_infoshows that the previous job ended and itscleanup_statusreadsComplete. -
After each move, at the routing endpoint, run a routed read of an object in the moved collocation, measure again, and compare with your starting table. Stop when you reach your goal.
-
If the busy member cluster still runs at its capacity limit, in the AWS CLI or the console, raise its capacity as a separate change. See Performance and scaling for Aurora serverless and Modifying an Amazon Aurora DB cluster. Routed statements run on the writer, so scale the writer for routed traffic. An added reader takes no routed reads.
Relieving a busy member cluster
When one collocation carries most of a member cluster's load, moving that collocation moves only its load. Instead, move the collocations around it. The busy collocation stays where it is and gets the full capacity of its member cluster.
For example, tenant_id = 42 accounts for most of member-b's statements, and its collocation is cg_07. With round-robin placement, member-b also holds cg_01, cg_04, and cg_10. You rebalance as follows:
-
Move
cg_01tomember-a, and then check routing and load. -
Move
cg_04tomember-c, and then check again. -
Move
cg_10ifmember-bis still near its capacity.
After the neighbors move, member-b serves only the busy tenant's collocation. If that tenant still needs more, raise member-b's capacity. To make this possible, give large tenants their own collocations when you design your placement. See Planning collocations and headroom.
Spreading data onto a new member cluster
Adding a member cluster doesn't change any data by itself. You put data on it by moving collocations onto it.
To spread data onto a new member cluster
-
In the AWS CLI or the console, add the member cluster. See Adding and removing member clusters.
-
At the routing endpoint, wait until
dbclustergroup_sys.member_cluster_mappingslists the new member cluster and a session pinned to it answers. Don't map or move anything onto it before then. -
For table mappings, on the new member cluster, through a direct connection or a pinned session, create the databases of the objects you move, under the same names.
-
Move collocations onto the new member cluster, one move for each collocation, as described in Moving a collocation.
A table that outgrows one member cluster needs a scaleout table instead. See Creating and loading a scaleout table.
Running on fewer member clusters
To run on fewer member clusters, move every collocation off the member cluster that you plan to remove, one move at a time. At the routing endpoint, read dbclustergroup_sys.data_mappings, and check that no mapping still names the member cluster's alias. The removal doesn't check the mappings for you. Then remove the member cluster. See Adding and removing member clusters.
The remaining member clusters hold each moved collocation as its own collocation. Two collocations that end up on the same member cluster stay separate, so you can move each of them again later.
When a move isn't the fix
Moving a collocation changes where data lives. It doesn't fix a single busy instance, a batch job that connects directly to one member cluster, or load that sits in one key value. To find the cause first, see Troubleshooting uneven load across member clusters. To change data placement in ways a move doesn't offer, see Copying data and running backfills.
Related pages
For related tasks and concepts, see the following pages: