# RGW multisite: realm, zonegroups, zones and the period

*HTML: https://book.ceph-s3.ir/en/lab-multisite.html*
*Licence: CC BY-NC-SA 4.0. Author: Ramin Najarbashi.*

[Interactive lab](lab.html)RGW multisite: realm, zonegroups, zones and the period
In the book: [Chapter 5](05-rgw-multisite.html#sec-05-4-4), [Chapter 42](42-spec-rgw-multisite-internals.html#sec-42-7), [K Multisite and DR](multisite-dr.html#multisite-dr-2)
LabRGW multisite: realm, zonegroups, zones and the periodLay out the realm, zonegroups and zones, pick the master zone, set the sync direction with sync-from or a sync policy, and see with period update --commit how the period moves on; also see the radosgw-admin commands for each step and the replication lag after a link outage.**p1 · 2**period · epoch**2**realm_epoch**eu-1**realm master zone in the current period**yes**uncommitted changeThese changes are not committed yet: the zones run the current period (epoch 2), and the arrows in the figure show that one too.Solid arrow: data pulled (from source to destination) in the committed period; dashed purple arrow: metadata from the realm's master zone to another zonegroup. Green frame: the realm's master zone, yellow: a zonegroup's master zone, dashed: a staged zone.Staged changes and their commandsIn the cluster of zone eu-3:`radosgw-admin realm pull --url=http://rgw-eu-1.example.com:80 --access-key=<AK> --secret=<SK>
radosgw-admin realm default --rgw-realm=gold
radosgw-admin period pull --url=http://rgw-eu-1.example.com:80 --access-key=<AK> --secret=<SK>
radosgw-admin zone create --rgw-zonegroup=europe --rgw-zone=eu-3 --endpoints=http://rgw-eu-3.example.com:80 --access-key=<AK> --secret=<SK>`In the cluster of zone eu-1:`radosgw-admin zone modify --rgw-zone=eu-1 --sync-from-all=false
radosgw-admin zone modify --rgw-zone=eu-2 --sync-from-all=false --sync-from=eu-1
radosgw-admin zone modify --rgw-zone=eu-3 --sync-from-all=false --sync-from=eu-1``radosgw-admin period update --commit   # on eu-1`Replication lag eu-1 → eu-2**10.1 s**typical lag of one object**91 / 50**sync rate / write rate (objects/s)**90000**backlog after the outage (objects)**36.7 min**catch-up timeObjects not yet at the destination: they rise at the write rate during the outage, then fall at the sync rate minus the write rate.If the source zone is lost at the end of the outage, about 90000 objects (about 90 GB) existed only there; multisite sync is asynchronous and its RPO is this backlog.lag ≈ poll/2 + 2·RTT + size/bw (poll = rgw_data_sync_poll_interval = 20 s) · μ = min(bw / size, in-flight / (2·RTT + in-flight · size / bw)) · in-flight = rgw_data_sync_spawn_window × RGWs = 20 backlog = writes/s × outage · catch-up = backlog / (μ − writes/s)`radosgw-admin sync status
radosgw-admin period get
radosgw-admin data sync status --source-zone=eu-1
radosgw-admin sync error list`The whole setup of this layout, cluster by cluster (chapter 5)In the cluster of zone eu-1:`radosgw-admin realm create --rgw-realm=gold --default
radosgw-admin zonegroup create --rgw-zonegroup=europe --endpoints=http://rgw-eu-1.example.com:80 --rgw-realm=gold --master --default
radosgw-admin zone create --rgw-zonegroup=europe --rgw-zone=eu-1 --endpoints=http://rgw-eu-1.example.com:80 --master --default
radosgw-admin user create --uid=sync-user --display-name="Multisite sync" --system
radosgw-admin zone modify --rgw-zone=eu-1 --access-key=<AK> --secret=<SK>
radosgw-admin period update --commit`In the cluster of zone eu-2:`radosgw-admin realm pull --url=http://rgw-eu-1.example.com:80 --access-key=<AK> --secret=<SK>
radosgw-admin realm default --rgw-realm=gold
radosgw-admin period pull --url=http://rgw-eu-1.example.com:80 --access-key=<AK> --secret=<SK>
radosgw-admin zone create --rgw-zonegroup=europe --rgw-zone=eu-2 --endpoints=http://rgw-eu-2.example.com:80 --access-key=<AK> --secret=<SK>
radosgw-admin period update --commit`In the cluster of zone eu-3:`radosgw-admin realm pull --url=http://rgw-eu-1.example.com:80 --access-key=<AK> --secret=<SK>
radosgw-admin realm default --rgw-realm=gold
radosgw-admin period pull --url=http://rgw-eu-1.example.com:80 --access-key=<AK> --secret=<SK>
radosgw-admin zone create --rgw-zonegroup=europe --rgw-zone=eu-3 --endpoints=http://rgw-eu-3.example.com:80 --access-key=<AK> --secret=<SK>
radosgw-admin period update --commit`In the cluster of zone eu-1:`radosgw-admin zone modify --rgw-zone=eu-1 --sync-from-all=false
radosgw-admin zone modify --rgw-zone=eu-2 --sync-from-all=false --sync-from=eu-1
radosgw-admin zone modify --rgw-zone=eu-3 --sync-from-all=false --sync-from=eu-1
radosgw-admin period update --commit``ceph orch apply rgw gold-eu-1 --realm=gold --zone=eu-1 --placement="label:rgw count-per-host:1" --port=80
ceph orch apply rgw gold-eu-2 --realm=gold --zone=eu-2 --placement="label:rgw count-per-host:1" --port=80
ceph orch apply rgw gold-eu-3 --realm=gold --zone=eu-3 --placement="label:rgw count-per-host:1" --port=80`Put the master zone where most metadata writes (bucket and user creation) come from, and check every zone's sync status before you move it. A sync policy sets the direction without touching each zone's sync-from list and also works per bucket; both ways take effect after period update --commit.Follows:`src/rgw/rgw_zone.cc :: fork_period, commit_period (FIRST_EPOCH, the master-zone check, epoch + 1)` Commit on the master zone, a higher epoch or a new period`src/rgw/radosgw-admin/radosgw-admin.cc :: zone modify --sync-from-all / --sync-from, sync group flow / pipe` Each zone's sync-from list, and the group, flow and pipe of a sync policy`src/common/options/rgw.yaml.in :: rgw_data_sync_poll_interval, rgw_data_sync_spawn_window, rgw_data_log_num_shards, rgw_data_notify_interval_msec` The sync defaults the lag model uses`doc/radosgw/multisite.rst, doc/radosgw/multisite-sync-policy.rst` The multisite and sync policy documentationA fixed snapshot of the simulator; the interactive version is in the web edition's lab. [Interactive lab: RGW multisite: realm, zonegroups, zones and the period](lab-multisite.html)The interactive version needs JavaScript; this is a fixed snapshot.
