Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add key transform functions for massive rate limit improvements #205

Open
wants to merge 24 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
6d41994
Change go-ds-s3 to utilizing prefixes
obo20 Aug 16, 2021
d905b50
bug fixes for the new data changes
obo20 Aug 17, 2021
d171f05
make the key tranformation pluggable
whyrusleeping Aug 21, 2021
7b5dccf
use a simple suffix config field to make text based configs easier
whyrusleeping Aug 21, 2021
2466cc3
Update s3ds.go
obo20 Aug 21, 2021
ce9300d
comma fix
obo20 Aug 21, 2021
dc5d2bd
Update go.mod
v-stickykeys Oct 14, 2021
e823c1b
feat: update to 3box module
v-stickykeys Oct 14, 2021
094a6c5
feat: add key transformation method for sharding (#1)
v-stickykeys Nov 1, 2021
2950104
fix: use string for key of map
v-stickykeys Nov 9, 2021
ec588c5
clean: remove dead code
v-stickykeys Nov 9, 2021
eb4e06a
feat: update next to last key syntax
v-stickykeys Nov 9, 2021
c052864
Update s3_test.go
v-stickykeys Nov 1, 2021
e024b96
feat: add key transform to optional field in test
v-stickykeys Nov 1, 2021
fa881fc
docs: add key transform to example config
v-stickykeys Nov 1, 2021
5317384
feat: update to go-ipfs 0.11
v-stickykeys Dec 10, 2021
f71e6d4
docs: clarify config instructions
v-stickykeys Dec 28, 2021
46a7177
docs: clarify config instructions
v-stickykeys Dec 28, 2021
f8b8a6b
Merge branch 'master' into master
v-stickykeys Dec 29, 2021
31a194d
docs: provide examples for sharding options
v-stickykeys Dec 30, 2021
5f32f2f
feat(test): randomize bucket name by default
v-stickykeys Jan 10, 2022
2982d65
fix(test): use default key transform by default
v-stickykeys Jan 10, 2022
f7d6fb9
feat(test): add key transform to config parser test
v-stickykeys Jan 10, 2022
0cc3de5
feat: Make it work with Kubo (#3)
ukstv Aug 29, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 33 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ As go plugins can be finicky to correctly compile and install, you may want to c
> export GO111MODULE=on

# Clone go-ipfs.
> git clone https://github.com/ipfs/go-ipfs
> cd go-ipfs
> git clone https://github.com/ipfs/kubo
> cd kubo

# Pull in the datastore plugin (you can specify a version other than latest if you'd like).
> go get github.com/ipfs/go-ds-s3/plugin@latest
> go get github.com/3box/go-ds-s3/plugin@latest

# Add the plugin to the preload list.
> echo "s3ds github.com/ipfs/go-ds-s3/plugin 0" >> plugin/loader/preload_list
> echo "s3ds github.com/3box/go-ds-s3/plugin 0" >> plugin/loader/preload_list

# ( this first pass will fail ) Try to build go-ipfs with the plugin
> make build
Expand All @@ -42,18 +42,18 @@ As go plugins can be finicky to correctly compile and install, you may want to c
# Now rebuild go-ipfs with the plugin
> make build

# (Optionally) install go-ipfs
# (Optionally) install go-ipfs aka Kubo
> make install
```

## Detailed Installation

For a brand new ipfs instance (no data stored yet):

1. Copy s3plugin.so $IPFS_DIR/plugins/go-ds-s3.so (or run `make install` if you are installing locally).
1. Copy `s3plugin.so` to `$IPFS_DIR/plugins/go-ds-s3.so` (or run `make install` if you are installing locally).
2. Run `ipfs init`.
3. Edit $IPFS_DIR/config to include s3 details (see Configuration below).
4. Overwrite `$IPFS_DIR/datastore_spec` as specified below (*Don't do this on an instance with existing data - it will be lost*).
3. Edit `$IPFS_DIR/config` to include s3 details for the **first** Datastore mount (see [Configuration](#configuration) below).
4. Overwrite `$IPFS_DIR/datastore_spec` (*Don't do this on an instance with existing data - it will be lost*. See [Configuration](#configuration) below).

### Configuration

Expand All @@ -68,11 +68,12 @@ The config file should include the following:
{
"child": {
"type": "s3ds",
"region": "us-east-1",
"region": "$bucketregion",
"bucket": "$bucketname",
"rootDirectory": "$bucketsubdirectory",
"accessKey": "",
"secretKey": ""
"secretKey": "",
"keyTransform": "$keytransformmethod"
},
"mountpoint": "/blocks",
"prefix": "s3.datastore",
Expand All @@ -81,6 +82,18 @@ The config file should include the following:
```

If the access and secret key are blank they will be loaded from the usual ~/.aws/.

The key transform allows you to specify how data is stored behind S3 keys. It must be one of the available methods:

`default`
- No sharding.

`suffix`
- Shards by storing block data at a key with a `data` suffix. E.g. `CIQJ7IHPGOFUJT5UMXIW6CUDSNH6AVKMEOXI3UM3VLYJRZUISUMGCXQ/data`

`next-to-last/2`
- Shards by storing block data based on the second to last 2 characters of its key. E.g. `CX/CIQJ7IHPGOFUJT5UMXIW6CUDSNH6AVKMEOXI3UM3VLYJRZUISUMGCXQ`
Comment on lines +94 to +95
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
`next-to-last/2`
- Shards by storing block data based on the second to last 2 characters of its key. E.g. `CX/CIQJ7IHPGOFUJT5UMXIW6CUDSNH6AVKMEOXI3UM3VLYJRZUISUMGCXQ`
`next-to-last/2`
- Shards by storing block data based on the second to last 2 characters of its key. E.g. `CX/CIQJ7IHPGOFUJT5UMXIW6CUDSNH6AVKMEOXI3UM3VLYJRZUISUMGCXQ`
- This is for compatibility with [js-datastore-s3](https://github.com/ipfs/js-datastore-s3)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For compatibility with js-datastore-s3 and also go-ds-flatfs. Don't think it's worth the note really. Seems most of the datastores utilize some form of sharding but next-to-last/2 happens to be the default for some.


If you are on another S3 compatible provider, e.g. Linode, then your config should be:

```json
Expand All @@ -93,12 +106,13 @@ If you are on another S3 compatible provider, e.g. Linode, then your config shou
{
"child": {
"type": "s3ds",
"region": "us-east-1",
"region": "$bucketregion",
"bucket": "$bucketname",
"rootDirectory": "$bucketsubdirectory",
"regionEndpoint": "us-east-1.linodeobjects.com",
"accessKey": "",
"secretKey": ""
"secretKey": "",
"keyTransform": "$keytransformmethod"
},
"mountpoint": "/blocks",
"prefix": "s3.datastore",
Expand All @@ -109,7 +123,7 @@ If you are on another S3 compatible provider, e.g. Linode, then your config shou
If you are configuring a brand new ipfs instance without any data, you can overwrite the datastore_spec file with:

```
{"mounts":[{"bucket":"$bucketname","mountpoint":"/blocks","region":"us-east-1","rootDirectory":"$bucketsubdirectory"},{"mountpoint":"/","path":"datastore","type":"levelds"}],"type":"mount"}
{"mounts":[{"bucket":"$bucketname","mountpoint":"/blocks","region":"$bucketregion","rootDirectory":"$bucketsubdirectory"},{"mountpoint":"/","path":"datastore","type":"levelds"}],"type":"mount"}
```

Otherwise, you need to do a datastore migration.
Expand All @@ -120,6 +134,12 @@ Feel free to join in. All welcome. Open an [issue](https://github.com/ipfs/go-ip

This repository falls under the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md).

### Local Development

```
go mod vendor
```

### Want to hack on IPFS?

[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md)
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
module github.com/ipfs/go-ds-s3
module github.com/3box/go-ds-s3

require (
github.com/aws/aws-sdk-go v1.35.30
github.com/ipfs/go-datastore v0.5.1
github.com/ipfs/go-ipfs v0.11.0-rc1
github.com/ipfs/kubo v0.14.0
)

go 1.15
Loading