Determining the Number of Shards in a Schema
- In unsharded mode, a schema corresponds only to one RDS DB instance, and only one shard is created for the RDS DB instance.
- In sharded mode, a schema corresponds to multiple RDS DB instances. By default, eight shards are created for each RDS DB instance. You can also create 16, 32, 64, or 128 shards for an RDS DB instance. The number of shards cannot be changed once it is configured.
Determining the Number of Shards per RDS DB Instance
The number of shards per RDS DB instance must be properly planned. If specifications of an RDS DB instance exceed the upper limit, system performance is affected. If the total number of shards is fixed, evaluate specifications of an RDS DB instance, and determine the relationship between RDS DB instances and shards per RDS DB instance.
The following are the shard calculation formulas:
- Total number of shards = {Total number of records}/{Number of records in an unsharded table} = {Number of RDS DB instances} x {Number of shards per RDS DB instance}
- {Number of records for a single RDS DB instance} = {Number of records in an unsharded table} x {Number of shards per RDS DB instance}
- Storage capacity of a single RDS DB instance = {Number of records in a single RDS DB instance} x {Number of bytes in a single record}
- Specifications of a single RDS DB instance include the storage capacity, throughput, response delay, connections, and physical resources.
For tables that need to be sharded horizontally, evaluate the expected service scale for the next one to two years. Determine the number of shards per RDS DB instance based on Table 1.
| Item | Calculation Method Reference | User Value | Example |
|---|---|---|---|
| Total number of records | Evaluated based on the service scale | Enter the actual value. | 1 billion = 1,000,000,000 |
| Number of records in an unsharded table | Evaluated based on the service scale | Enter the actual value. | 10,000,000 |
| Total number of shards | {Total number of records}/{Number of records in an unsharded table} ({Number of RDS DB instances} x {Number of shards per RDS DB instance}) | Enter the actual value. | 100 |
| Number of RDS DB instances | For details, see Determining the Number of RDS DB Instances. | Enter the actual value. | 4 |
| Number of shards per RDS DB instance | {Total number of shards}/{Number of RDS DB instances} Enumeration value: [8, 16, 32, 64, 128] NOTE:
| Enter the actual value. | 32 |
Last Article: Determining the Number of RDS DB Instances
Next Article: Selecting a Sharding Key and a Sharding Algorithm
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.