使用DynamoDB的小型应用采用均匀分布分区键是否有实际意义?
Great question—this is a super common point of confusion with DynamoDB, especially for folks building smaller applications. Let's break it down clearly:
First, yes, Amazon DynamoDB emphasizes that evenly distributing your partition key is a core principle for proper schema design. But here's the thing: many small apps will never exceed the limits of a single partition, so that distribution might not matter for you right now.
Here's how DynamoDB calculates how many partitions you'll need (per their official guidelines):
The number of partitions is determined by:
(readCapacityUnits / 3000) + (writeCapacityUnits / 1000)
Let's use a real-world small app example. Say you've provisioned 1000 strongly consistent read capacity units (RCUs) and 500 write capacity units (WCUs). Plugging those numbers in:(1000 / 3000) + (500 / 1000) ≈ 0.33 + 0.5 = 0.83
DynamoDB rounds this up to the nearest whole number, so you'd only get 1 partition. And as long as two conditions hold, you'll stay on that single partition indefinitely:
- Your total data storage stays under 10GB (the maximum storage per partition)
- Your actual throughput never spikes beyond the single-partition limits: 3000 strongly consistent RCUs, 6000 eventually consistent RCUs, or 1000 WCUs
That said, even if you don't need it today, it's smart to choose a high-cardinality partition key (like a unique user ID or UUID) anyway. If your app does grow later, refactoring your partition key to fix distribution issues is a massive headache—better to build in that scalability from the start, even if it feels overkill now.
内容的提问来源于stack exchange,提问作者Arsenii Fomin

