TT Lab
Get started
Learn Learning paths Courses

Object Storage and S3

Starting SeaweedFS and Storing and Retrieving Files

Continue in TT Lab

Goal

Start SeaweedFS's master, volume server and filer yourself and store and look up files with the low-level API, to confirm why this structure is advantageous for workloads with huge numbers of small files.

Why it matters

A million 4KB files are 4GB as data but a million metadata entries to the filesystem. Inodes run out, listing takes minutes, and backup tools spend days stat-ing each file. SeaweedFS follows the approach of Facebook's Haystack and writes small files one after another inside a large volume file, remembering only the offsets. If 1,000 files go into one volume file, there is one inode and a read is a single seek. What matters especially in this lab are steps 3–5 — asking the master for a location, writing directly to the volume server, and asking for the location again to read; this flow is the whole of SeaweedFS. The filer and the S3 gateway are only convenience layers on top, and once you understand these two steps, you can see why the master does not become a bottleneck.

Steps

  1. Create the /root/sw/master directory and start weed master on 127.0.0.1:9333. curl http://127.0.0.1:9333/cluster/status returns JSON.
  2. Create /root/sw/vol1 and start weed volume on 127.0.0.1:8180, registering it with the master. The response of curl http://127.0.0.1:9333/dir/status must show at least one volume server.
  3. From the result of curl http://127.0.0.1:9333/dir/assign, save the fid in /root/sw/fid.txt. It must be in the form 숫자,16진문자열 (a number, a comma, then a hexadecimal string).
  4. Upload /opt/fixtures/s3/readme.txt to the volume server with that fid. The size in the response must be greater than 0.
  5. Find the location with /dir/lookup?volumeId=<볼륨ID> (the volume ID in the placeholder) and download the file to /root/sw/got.txt. Its content must be the same as the original.
  6. Start weed filer on 127.0.0.1:8888. PUT /opt/fixtures/s3/sales.csv to http://127.0.0.1:8888/lab/sales.csv, GET it back and create /root/sw/filer.csv. The content must be the same.
  7. With /root/sw/many.sh, put 500 files of 4KiB under the filer's /lab/small/. In /root/sw/volfiles.txt, write files=500 dat_files=<n>, where n must be 10 or less.
  8. In /root/sw/arch.md, put three headings, ## 마스터 (master), ## 볼륨 서버 (volume server) and ## 파일러 (filer), and write at least 25 characters in each section. The master section must say that it holds no metadata.

Notes

Start the master

Create the /root/sw/master directory and start weed master on 127.0.0.1:9333. curl http://127.0.0.1:9333/cluster/status returns JSON.

You start each role as a subcommand of the weed binary. Create the data directory beforehand.

Start a volume server and register it with the master

Create /root/sw/vol1 and start weed volume on 127.0.0.1:8180, registering it with the master. The response of curl http://127.0.0.1:9333/dir/status must show at least one volume server.

The volume server must know the master's address. Check that the volume server appears in the master's status.

Get a file ID issued

From the result of curl http://127.0.0.1:9333/dir/assign, save the fid in /root/sw/fid.txt. It must be in the form 숫자,16진문자열 (a number, a comma, then a hexadecimal string).

If you ask the master for a write location, it gives you a file identifier together with a server address.

Upload a file with the issued ID

Upload /opt/fixtures/s3/readme.txt to the volume server with that fid. The size in the response must be greater than 0.

You upload to the volume server, not the master. The master only tells you locations.

Look it up, download it and check the content

Find the location with /dir/lookup?volumeId=<볼륨ID> (the volume ID in the placeholder) and download the file to /root/sw/got.txt. Its content must be the same as the original.

Ask for the location by volume ID and download from that server. It must be the same as the original.

Start the filer and work by path

Start weed filer on 127.0.0.1:8888. PUT /opt/fixtures/s3/sales.csv to http://127.0.0.1:8888/lab/sales.csv, GET it back and create /root/sw/filer.csv. The content must be the same.

The filer provides path-based access. You can handle it with HTTP PUT and GET.

Put in 500 small files and check the number of volume files

With /root/sw/many.sh, put 500 files of 4KiB under the filer's /lab/small/. In /root/sw/volfiles.txt, write files=500 dat_files=<n>, where n must be 10 or less.

Count how many volume files the 500 files end up in. This is the reason this storage exists.

Summarize the roles of the three daemons

In /root/sw/arch.md, put three headings, ## 마스터 (master), ## 볼륨 서버 (volume server) and ## 파일러 (filer), and write at least 25 characters in each section. The master section must say that it holds no metadata.

The key is what holds metadata and what holds data. Write the specified headings exactly.