The Comprehensive Ceph Guide
فارسیGet started

Bucket index shards and dynamic reshard

In the book: Chapter 4

Lab

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.

521shards now
5reshards so far
57.6kobjects per shard
8 × 521entries read for a page of 1000
1k10k100k1M10M100M1G11110119992961127257521
Shard count (vertical, log) as the bucket grows (horizontal, log). Each step is a reshard and the number next to it the new shard count; the vertical line is the bucket's current size.
#at objectsshardskind
11.2M11 → 29expansion
23M29 → 61expansion
36.2M61 → 127expansion
412.8M127 → 257expansion
525.8M257 → 521expansion

2000 sample keys over 521 shards: 0 keys in the emptiest shard and 10 in the fullest.

expand if objects > shards × 100000 · reduce if shards > 11 and objects < shards × 1000
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_primes the expansion and reduction tests, the factor 2 or 8 and rounding to a prime
  • src/rgw/driver/rados/rgw_rados.cc :: RGWRados::calculate_preferred_shards, check_bucket_shards; src/rgw/rgw_quota.cc :: RGWOwnerStatsCache::sync_bucket the threshold divided by 3 for versioned buckets, and the multisite test
  • src/rgw/driver/rados/rgw_rados.cc :: RGWRados::calc_ordered_bucket_list_per_shard the entries read from each shard in an ordered listing
  • src/rgw/services/svc_bi_rados.h :: RGWSI_BucketIndex_RADOS::bucket_shard_index; src/common/ceph_hash.cc :: ceph_str_hash_linux the shard of each key
  • src/common/options/rgw.yaml.in :: rgw_max_objs_per_shard (100000), rgw_max_dynamic_shards (1999), rgw_dynamic_resharding_reduction_wait (120) the defaults
A fixed snapshot of the simulator; the interactive version is in the web edition's lab. Interactive lab: Bucket index shards and dynamic reshard