dynamoDBのpartition分割

dynamoDBはstorage sizeとthroughputが大きくなるにつれてpartitonを増やしていく
その際の挙動について調べたのでメモ

partitionとprimary keyの関係について
Partitions and Data Distribution - Amazon DynamoDB

partition分割時の挙動について
Guidelines for Working with Tables - Amazon DynamoDB

1つのpartitonは

  • 10GBのデータを保持できる
  • readだけなら3000, writeだけなら1000のcapacityをサポートできる

これを超えるとpartitoinは分割される

あるitemがどのpartitionに含まれるかはhash keyの値をhash関数で処理した値によって決まる

To write an item to the table, DynamoDB uses the value of the partition key as input to an internal hash function. The output value from the hash function determines the partition in which the item will be stored.

Guidelines for Working with Tables - Amazon DynamoDB
のdocumentでも説明されている内容によると、partition分割時にはitemが均等に分割されると図を用いて描かれている

1. Allocate two new partitions (P1 and P2).
2. Distribute the data from P evenly across P1 and P2.
3. Deallocate P from the table.

ただ、hash keyが同一であれば同じpartitionに属するはずなのでhash keyの選び方によっては均等に分割されるとは限らないと考えられる、というか均等になるようにhash keyを選ぶべきということか。

ちなみにGlobal Secondary Indexを用いるときも上記の内容を考慮してhash keyを選ぶ必要がある
Guidelines for Global Secondary Indexes - Amazon DynamoDB

疑問点

例えば以下のようなhask keyがあったとする

  • hash key = 1, 2, 3, 4のどれかの値
  • 各値ごとに含まれるitem数はそれぞれ1000, 2000, 3000, 4000

この場合、partitionを4つに分けるとすれば一つのpartitionが一つのhash keyを担当する形になるのだと思う。

ではこれを2 partitionに分割する場合は?

  • hash keyが(1, 4)と(2, 3)の組み合わせでitem数がそれぞれ5000ずつとなるように分割してくれるのだろうか?
  • hash keyを若い方から見ていって半分ずつくらいになるところまでが一つのpartitionとなるのだろうか?
    • この例だと(1,2,3)と(4)に分割されるという意味

この辺はparition分割の実装次第になるのだろうが詳細に解説しているdocumentは見つけられなかった。