Resharding
The storage-api-reshard
utility explores moving data from N old shards to M new shards, where M, N is the full shards count on installation.
To get the information about command line parameters for storage-api-reshard
utility, run the following command:
docker run --rm -ti --entrypoint "/storage-api-reshard" docker.int.ntl/ntech/universe/sf-api:ffserver-11.240325 --help
The most important command line flags are the following:
Command line flags |
Type |
Description |
---|---|---|
|
string |
Path to config file. |
|
– |
Output config template and exit. |
|
– |
Delete migrated faces on old shard (default true). |
|
– |
Do not add/delete faces, perform only read requests (default true). |
|
string |
Gallery to reshard (default “history”). |
|
– |
Print help information. |
|
uint |
Max object id for execution (default 18446744073709551615). |
|
uint |
Min object id for execution. |
|
[]string |
List of new shards url. |
|
[]string |
List of old shards url. |
|
int |
Execute migration for old_shards[idx]. Required parameter. On one execution only 1 old shard can be migrated to new shards. |
Warning
It’s recommended to create a dump before resharding.
To run the storage-api-reshard
utility, do the following:
Create a default
storage-api-reshard
configuration file.docker run --rm -ti --entrypoint "/storage-api-reshard" docker.int.ntl/ntech/universe/sf-api:ffserver-11.240325 \ --config-template > /opt/ffserver/configs/storage-api-reshard.yaml
/opt/ffserver/configs/
: the directory on the host to store the configuration file.
Modify configuration file:
... gallery: history min_face_id: 0 max_face_id: 18446744073709551615 shard_idx: 0 dry_run: true delete_old: true old_shards: - http://tnt-1-1:8001/v2/ - http://tnt-2-1:8001/v2/ new_shards: [] - http://tnt-1-1:8001/v2/ - http://tnt-2-1:8001/v2/ - http://tnt-3-1:8001/v2/ ...
Important
storage-api-resharder
makes decisions based solely on shard number, so thenew_shards
list should be either shortened version ofold_shards
when scaling down, or the same asold_shards
plus a few new lines when scaling up.Run
storage-api-reshard
utility with the configuration file indry_run
to check your configuration.docker run --rm -ti --network server --entrypoint "/storage-api-reshard" \ --volume /opt/ffserver/configs/storage-api-reshard.yaml:/storage-api-reshard.yaml \ docker.int.ntl/ntech/universe/sf-api:ffserver-11.240325 \ --config /storage-api-reshard.yaml
Console output:
Config: --- gallery: face:test min_face_id: 0 max_face_id: 18446744073709551615 shard_idx: 0 dry_run: true delete_old: true old_shards: - http://tnt-1-1:8001/v2 - http://tnt-2-1:8001/v2 new_shards: - http://tnt-1-1:8001/v2 - http://tnt-2-1:8001/v2 - http://tnt-3-1:8001/v2 ... 2024/06/06 06:58:47 SAR-BpLnfgDs | got faces(4 ... 6), will migrate 3/3 2024/06/06 06:58:47 SAR-BpLnfgDs | total:3 migrated:3 migrateRatio:1.00 duration:0.00s speed:2138.16/s 2024/06/06 06:58:47 Done
Run the
storage-api-reshard
utility with the configuration file withoutdry_run
mode for all shard idx for migration.