Learn Labs
Durability

Replication & Placement

The xyz placement code, racks and data centers, and repairing missing copies

SeaweedFS replicates volumes, not objects. Every object in a volume has exactly as many copies as the volume, on the same servers. The number and placement of copies is a three-digit code.

The placement code xyz

DigitExtra copies
xIn other data centers
yOn other racks in the same data center
zOn other servers in the same rack
CodeCopiesSurvives
0001Nothing. What you get if you don't set one
0012One server, not its rack
0102One rack (this lab's default)
1002One data center
2003Two data centers

The masters run with -defaultReplication=010. A bucket can use a different code (in the filer's per-path configuration, fs.configure in weed shell), so scratch data can be 000 and invoices 010.

rack1 / volume-1volume 4 (copy)rack2 / volume-2rack3 / volume-3volume 4 (copy)rack4 / volume-4masterplacement 010xyz = 0 other data centers, 1 other rack, 0 other servers in the same rack
docker compose -f compose_prod.yaml run --rm labs python needles.py
volume 4 is on ['volume-1:8080', 'volume-3:8080']  (replication 010: two copies, different racks)
rack1/volume-1:8080: volume 4 size 171184 files 4 replication {'rack': 1}
rack3/volume-3:8080: volume 4 size 171184 files 4 replication {'rack': 1}

Writes are synchronous

The volume server that receives a write forwards it to every other replica and answers only when all of them have it. A 200 OK means every copy is on disk. The cost: a write is as slow as the slowest replica, and a write fails if any replica of the chosen volume is unreachable. The master works around that by assigning new writes only to volumes whose replicas are all up. With one of four servers down, writes kept working. With two down, new writes failed with InternalError in the drill, even though two racks were still up. Lab question 4 asks you to find out why.

Losing a copy

When a volume server dies, its volumes are under-replicated: one copy left. SeaweedFS doesn't repair this on its own, because a server that's rebooting would otherwise trigger terabytes of copying. You decide:

docker stop volume-4
docker exec -it master-1 weed shell -master=master-1:9333
> lock
> volume.fix.replication                 # dry run
Running in simulation mode. Use "-apply" option to apply the changes.
volume 38 replication 010, but under replicated +1
...
replicating volume 42 010 from volume-3:8080 to dataNode volume-2:8080 ...
replicating volume 39 010 from volume-2:8080 to dataNode volume-3:8080 ...
failed to place volume 38 replica as 010, existing:1
failed to place volume 45 replica as 010, existing:1
failed to place volume 44 replica as 010, existing:1
failed to place volume 34 replica as 010, existing:1
> volume.fix.replication -apply          # actually copy

Four volumes couldn't be repaired: the three remaining servers had only 10 free volume slots between them. Repair needs spare capacity.

Here the server came back instead. Its volumes rejoined, and the dry run reported nothing to fix. The SeaweedFS_master_under_replicated_volumes metric took about 5 minutes longer to drop back to 0, because the leader only recounts it on its periodic volume-growth pass. Alerts on it need a for: longer than that, or they flap.

Other housekeeping

volume.balancedry run: even out volumes across serversvolume.balance -applyvolume.fix.replication -applyalso removes over-replicated copies (-doDelete, default true)volume.check.diskcompare replicas of each volume, find mismatchesvolume.vacuumreclaim space from deleted needlesvolume.tier.uploadmove a cold volume's .dat to S3-compatible cloud storage

Lab

  1. Stop volume-4, run volume.fix.replication dry, then with -apply. Start volume-4 again. What does the cluster do with the extra copies?
  2. Write to a bucket configured for 000 and stop the server holding its volume. What happens on GET?
  3. Run volume.check.disk and read what it compares.
  4. Stop volume-2 and volume-3, then try a write and read the leader master's log and volume.list. Which volumes were writable, where were their copies, and did the master grow new ones on the survivors?

On this page