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

[Merged by Bors] - feature: Replica assignment #651

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
41 changes: 41 additions & 0 deletions content/cli/commands/topic.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,47 @@ topic "my-topic" created

In this example, the topic `my-topic` will be created with compression type `gzip`.

### replication assignment

By default, Fluvio will automatically assign replicas to SPUs. However, you can manually assign replicas to SPUs by using the `--replica-assignment` flag.

Please refer to following [replica]({{<ref "/docs/architecture/replica-.md">}}) sections for detail of replica assignment.

Note that in order to replication assignment to work, you need to have at least 2 SPUs in your cluster.

Example usage:

In this example, we assign first replica to SPU 0, second replica to SPU 1.
First we create replica assignment file `replica.json`.
```json
[
{
"id": 0,
"replicas": [
0,
1
]
}
]
```
The `replicas` fields correspond to the SPU ids. You can get SPU ids by running `fluvio cluster spu list`.

Then we create topic with replica assignment file.
```bash
$ fluvio topic create my-topic --replica-assignment replica.json
topic "my-topic" created
```

Use partition commands to show that topic has been created with replica assignment.

```bash

$ fluvio partition list
TOPIC PARTITION LEADER REPLICAS RESOLUTION SIZE HW LEO LRS FOLLOWER OFFSETS
my-topic 0 0 [1] Online 0 B 0 0 0 0 [ReplicaStatus { spu: 1, hw: -1, leo: -1 }]

```
## `fluvio topic list`
This command shows you all the existing topics in your cluster, as well as some basic
Expand Down
36 changes: 17 additions & 19 deletions content/docs/architecture/replica-assignment.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ The algorithm uses a **round-robin**, **gap-enabled** distribution assignment.

In a cluster with **4** SPUs, a topic created with:

| Replicas | Partitions |
|:------------:|:-------------:|
| **3** | **15** |
| Replicas | Partitions |
| :------: | :--------: |
| **3** | **15** |

The algorithm generates the following replica distribution:

Expand Down Expand Up @@ -110,9 +110,9 @@ The algorithm has the following 3 stages:

On a cluster with **12** SPUs evenly distributed across **4** racks, a topic created with:

| Replicas | Partitions |
|:------------:|:-------------:|
| **4** | **12** |
| Replicas | Partitions |
| :------: | :--------: |
| **4** | **12** |


The **3-stage** algorithm generates the following distribution:
Expand Down Expand Up @@ -164,9 +164,9 @@ On a cluster with **6** SPUs unevenly distributed across **3** racks:

For a topic created with:

| Replicas | Partitions |
|:------------:|:-------------:|
| **3** | **6** |
| Replicas | Partitions |
| :------: | :--------: |
| **3** | **6** |

The **3-stage** algorithm generates the following distribution:

Expand Down Expand Up @@ -219,17 +219,15 @@ _Validate-only_ flag is available to verify a replica assignment file without ap
**Replica assignment file** defines a **replica map** in JSON format. A replica map with 2 partitions and 3 replicas is defined as follows:

```json
{
"partitions": [{
"id": 0,
"replicas": [0, 1, 2]
},
{
"id": 1,
"replicas": [1, 2, 0]
}
]
[{
"id": 0,
"replicas": [0, 1, 2]
},
{
"id": 1,
"replicas": [1, 2, 0]
}
]
```

The **replica map** definition meet the following criteria:
Expand Down
Loading