# S3 in the CrushMFT layout

S3 is slow at the things a file server does all day: listing folders, renaming, moving. The item type **S3Crush** of a [VFS](VFS.md) gets around that. It keeps the **data** of the files in an S3 bucket and the **tree** of names and folders on the server's own disk.

## How it works

| | Kept where |
|---|---|
| the folders, the names, sizes and dates | on the server, as small files in the folder `s3` of the server's folder, one folder per bucket |
| what is in the files | in the bucket, one object per file |

- Listing a folder reads a local folder. It is as fast as the disk.
- Renaming or moving a file or a whole folder changes local files only. Nothing is copied in S3.
- Uploading and downloading go to and from the bucket, as with the type S3.

## Against plain S3

| | S3 | S3Crush |
|---|---|---|
| listing, renaming, moving | as slow as S3 | fast |
| the bucket is usable by other programs | yes: the objects have the files' names | only with **Use Random ID?** off, and then without later renames |
| what a backup needs | the bucket | the bucket **and** the server's `s3` folder |
| several CrushMFT servers on one bucket | yes | only if they share the `s3` folder, or it is replicated between them |

Use S3Crush when CrushMFT is the only door to the data and people work in it as in a file system. Use plain [S3](VFS-S3.md) when other programs read the same bucket.

## The settings

The dialog is that of S3: see [Amazon S3](VFS-S3.md) for the address, the login and the options. Two are its own:

| Option | What it does | New item |
|---|---|---|
| **Use Random ID?** | each stored file gets a random part in the name of its object. A file can then be renamed and replaced without touching S3, and two uploads of the same name never collide. Off: the object is named like the file. | on |
| **Store files split into segments.** | a file is stored as several objects, one per part, instead of being joined into one at the end of the upload | off |

## The local folder

The folder `s3` in the server's folder is the map. Without it, the bucket is a heap of objects with random names.

- **Back it up** with the server, as often as the data changes.
- Put it on a disk that is as safe as the data is important.
- In a cluster, all servers need the same map: put the folder on storage they share. Its place is the Java setting `crushmft.s3_root` on the server's command line.
- Never clean up the bucket by hand, and never the folder: a pointer without its object is a file that cannot be read, and an object without its pointer is space that is paid for and unreachable.

## Moving in and out

Files that are already in a bucket are not seen by an S3Crush item: they have no pointer. To bring existing data in, copy it in through CrushMFT, for instance with a job from an item of type S3 to an item of type S3Crush. The same way leads out again.
