Bucket index shards and dynamic reshard
In the book: Chapter 4
Bucket index shards and dynamic reshard
Grow a bucket to millions of objects and see when dynamic reshard splits it and into how many shards, how keys spread over the shards, and how many entries one page of an ordered listing reads from them.
| # | at objects | shards | kind |
|---|---|---|---|
| 1 | 1.2M | 11 → 29 | expansion |
| 2 | 3M | 29 → 61 | expansion |
| 3 | 6.2M | 61 → 127 | expansion |
| 4 | 12.8M | 127 → 257 | expansion |
| 5 | 25.8M | 257 → 521 | expansion |
2000 sample keys over 521 shards: 0 keys in the emptiest shard and 10 in the fullest.
new = clamp(⌊objects × 2 / 100000⌋, 11, 1999) → next prime in reshard_primes · ordered listing reads max(8, 1 + ⌊n/s⌋ + √(2n·ln s / s)) = 8 entries from each of 521 shards
Each reshard rewrites every index entry and, in multisite, starts a new bilog generation. Many shards in turn make ordered listings expensive: with 1999 shards every page sends 1999 cls calls. For listings that need no order use allow-unordered (chapter 4).
Follows:
src/rgw/driver/rados/rgw_reshard.cc :: RGWBucketReshard::calculate_preferred_shards, nearest_prime, reshard_primesthe expansion and reduction tests, the factor 2 or 8 and rounding to a primesrc/rgw/driver/rados/rgw_rados.cc :: RGWRados::calculate_preferred_shards, check_bucket_shards; src/rgw/rgw_quota.cc :: RGWOwnerStatsCache::sync_bucketthe threshold divided by 3 for versioned buckets, and the multisite testsrc/rgw/driver/rados/rgw_rados.cc :: RGWRados::calc_ordered_bucket_list_per_shardthe entries read from each shard in an ordered listingsrc/rgw/services/svc_bi_rados.h :: RGWSI_BucketIndex_RADOS::bucket_shard_index; src/common/ceph_hash.cc :: ceph_str_hash_linuxthe shard of each keysrc/common/options/rgw.yaml.in :: rgw_max_objs_per_shard (100000), rgw_max_dynamic_shards (1999), rgw_dynamic_resharding_reduction_wait (120)the defaults