Skip to content
Open
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
29 changes: 16 additions & 13 deletions docs/develop/worker-performance.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,8 @@ These examples focus on Activities and Local Activities, since Workflow Tasks no
### Go SDK

```go
import "go.temporal.io/sdk/contrib/resourcetuner"

// Using the ResourceBasedTuner in worker options
tuner, err := resourcetuner.NewResourceBasedTuner(resourcetuner.ResourceBasedTunerOptions{
TargetMem: 0.8,
Expand All @@ -457,36 +459,37 @@ if err != nil {
return err
}
workerOptions := worker.Options{
Tuner: tuner
Tuner: tuner,
}
// Combining different types
options := DefaultResourceControllerOptions()

// Customize the tuner
options := resourcetuner.DefaultResourceControllerOptions()
options.MemTargetPercent = 0.8
options.CpuTargetPercent = 0.9
controller := NewResourceController(options)
controller := resourcetuner.NewResourceController(options)
wfSS, err := worker.NewFixedSizeSlotSupplier(10)
if err != nil {
return err
}
actSS := &ResourceBasedSlotSupplier{controller: controller,
options: defaultActivityResourceBasedSlotSupplierOptions()}
laSS := &ResourceBasedSlotSupplier{controller: controller,
options: defaultActivityResourceBasedSlotSupplierOptions()}

actSS, err := resourcetuner.NewResourceBasedSlotSupplier(controller, resourcetuner.DefaultActivityResourceBasedSlotSupplierOptions())
laSS, err := resourcetuner.NewResourceBasedSlotSupplier(controller, resourcetuner.DefaultActivityResourceBasedSlotSupplierOptions())
nexusSS, err := worker.NewFixedSizeSlotSupplier(10)
if err != nil {
return err
}

compositeTuner, err := worker.NewCompositeTuner(worker.CompositeTunerOptions{
WorkflowSlotSupplier: wfSS,
ActivitySlotSupplier: actSS,
LocalActivitySlotSupplier: laSS,
NexusSlotSupplier: nexusSS,
WorkflowSlotSupplier: wfSS,
ActivitySlotSupplier: actSS,
LocalActivitySlotSupplier: laSS,
NexusSlotSupplier: nexusSS,
})
if err != nil {
return err
}
workerOptions := worker.Options{
Tuner: compositeTuner
Tuner: compositeTuner,
}
```

Expand Down
153 changes: 73 additions & 80 deletions docs/encyclopedia/temporal-service/multi-cluster-replication.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ T = 0: adding event with event ID == 1 & version == 1
View in both Cluster A & B

```
| -------- | ------------- | --------------- | ------- |
| -------- | --------------- | --------------- | ------- |
| Events | Version History |
| -------- | --------------- | --------------- | ------- |
| Event ID | Event Version | Event ID | Version |
Expand All @@ -146,7 +146,7 @@ T = 1: adding event with event ID == 2 & version == 1
View in both Cluster A & B

```
| -------- | ------------- | --------------- | ------- |
| -------- | --------------- | --------------- | ------- |
| Events | Version History |
| -------- | --------------- | --------------- | ------- |
| Event ID | Event Version | Event ID | Version |
Expand All @@ -161,7 +161,7 @@ T = 2: adding event with event ID == 3 & version == 1
View in both Cluster A & B

```
| -------- | ------------- | --------------- | ------- |
| -------- | --------------- | --------------- | ------- |
| Events | Version History |
| -------- | --------------- | --------------- | ------- |
| Event ID | Event Version | Event ID | Version |
Expand All @@ -178,7 +178,7 @@ adding event with event ID == 4 & version == 2
View in both Cluster A & B

```
| -------- | ------------- | --------------- | ------- |
| -------- | --------------- | --------------- | ------- |
| Events | Version History |
| -------- | --------------- | --------------- | ------- |
| Event ID | Event Version | Event ID | Version |
Expand All @@ -195,7 +195,7 @@ T = 4: adding event with event ID == 5 & version == 2
View in both Cluster A & B

```
| -------- | ------------- | --------------- | ------- |
| -------- | --------------- | --------------- | ------- |
| Events | Version History |
| -------- | --------------- | --------------- | ------- |
| Event ID | Event Version | Event ID | Version |
Expand Down Expand Up @@ -229,7 +229,7 @@ T = 0:
View in both Cluster B & C

```
| -------- | ------------- | --------------- | ------- |
| -------- | --------------- | --------------- | ------- |
| Events | Version History |
| -------- | --------------- | --------------- | ------- |
| Event ID | Event Version | Event ID | Version |
Expand All @@ -243,7 +243,7 @@ View in both Cluster B & C
T = 1: adding event with event ID == 4 & version == 2 in Cluster B

```
| -------- | ------------- | --------------- | ------- |
| -------- | --------------- | --------------- | ------- |
| Events | Version History |
| -------- | --------------- | --------------- | ------- |
| Event ID | Event Version | Event ID | Version |
Expand All @@ -258,7 +258,7 @@ T = 1: adding event with event ID == 4 & version == 2 in Cluster B
T = 1: namespace failover to Cluster C, adding event with event ID == 4 & version == 3 in Cluster C

```
| -------- | ------------- | --------------- | ------- |
| -------- | --------------- | --------------- | ------- |
| Events | Version History |
| -------- | --------------- | --------------- | ------- |
| Event ID | Event Version | Event ID | Version |
Expand All @@ -275,40 +275,38 @@ T = 2: replication task from Cluster C arrives in Cluster B
Note: below are a tree structures

```
| -------- | ------------- |
| Events |
| ------------- | ------------- |
| Event ID | Event Version |
| -------- | ------------- |
| 1 | 1 |
| 2 | 1 |
| 3 | 2 |
| -------- | ------------- |
| |
| ------------- | ------------ |
| |
| -------- | ------------- | | -------- | ------------- |
| Event ID | Event Version | | Event ID | Event Version |
| -------- | ------------- | | -------- | ------------- |
| 4 | 2 | | 4 | 3 |
| -------- | ------------- | | -------- | ------------- |

| --------------- | ------- |
| Version History |
| --------------- | ------------------- |
| Event ID | Version |
| --------------- | ------- |
| 2 | 1 |
| 3 | 2 |
| --------------- | ------- |
| |
| ------- | ------------------- |
| |
| --------------- | ------- | | --------------- | ------- |
| Event ID | Version | | Event ID | Version |
| --------------- | ------- | | --------------- | ------- |
| 4 | 2 | | 4 | 3 |
| --------------- | ------- | | --------------- | ------- |
| ------------- | ------------- |
| Events |
| ------------- | ------------- |
| Event ID | Event Version |
| ------------- | ------------- |
| 1 | 1 |
| 2 | 1 |
| 3 | 2 |
| -------- | ------------- |
| |
| |
| -------- | ------------- | | -------- | ------------- |
| Event ID | Event Version | | Event ID | Event Version |
| -------- | ------------- | | -------- | ------------- |
| 4 | 2 | | 4 | 3 |
| -------- | ------------- | | -------- | ------------- |

| --------------- | ------------------- |
| Version History |
| --------------- | ------------------- |
| Event ID | Version |
| --------------- | ------- |
| 2 | 1 |
| 3 | 2 |
| --------------- | ------------------- |
| |
| |
| --------------- | ------- | | --------------- | ------- |
| Event ID | Version | | Event ID | Version |
| --------------- | ------- | | --------------- | ------- |
| 4 | 2 | | 4 | 3 |
| --------------- | ------- | | --------------- | ------- |
```

T = 2: replication task from Cluster B arrives in Cluster C, same as above
Expand Down Expand Up @@ -345,27 +343,22 @@ Multi-cluster Replication aims to keep the Workflow Execution History as up-to-d
Due to the nature of Multi-cluster Replication (for example, Workflow Execution History events are replicated asynchronously) different Runs (same Namespace and Workflow Id) can arrive at the target Cluster at different times, sometimes out of order, as shown below:

```
| ------------- | | ------------- | | ------------- |
| Cluster A | | Network Layer | | Cluster B |
| --------- || ------------- | | ------------- |
| | |
| Run 1 Replication Events | |
| -----------------------> | |
| | |
| Run 2 Replication Events | |
| -----------------------> | |
| | |
| | |
| | |
| | Run 2 Replication Events |
| | -----------------------> |
| | |
| | Run 1 Replication Events |
| | -----------------------> |
| | |
| --- || ------------- | | ------------- |
| Cluster A | | Network Layer | | Cluster B |
| --------- || ------------- | | ------------- |
+-----------+ +----------------+ +-----------+
| Cluster A | | Network Layer | | Cluster B |
+-----------+ +----------------+ +-----------+
| | |
| Run 1 Replication | |
|---------------------> | |
| | |
| Run 2 Replication | |
|---------------------> | |
| | |
| | Run 2 Replication |
| |---------------------> |
| | |
| | Run 1 Replication |
| |---------------------> |
| | |
```

Because Run 2 appears in Cluster B first, Run 1 cannot be replicated as "runnable" due to the rule `at most one Run open` (see above), thus the "zombie" Workflow Execution state is introduced.
Expand Down Expand Up @@ -407,23 +400,23 @@ T = 0: task A is generated according to Event Id: 4, version: 2
T = 1: conflict resolution happens, Workflow Execution's mutable state is rebuilt and history Event Id: 4, version: 3 is written down to persistence

```
| -------- | ------------- |
| Events |
| ------------- | -------------------------------------------- |
| Event ID | Event Version |
| -------- | ------------- |
| 1 | 1 |
| 2 | 1 |
| 3 | 2 |
| -------- | ------------- |
| |
| ------------- | -------------------------------------------- |
| |
| -------- | ------------- | | -------- | ------------- |
| Event ID | Event Version | | Event ID | Event Version |
| -------- | ------------- | | -------- | ------------- |
| 4 | 2 | <-- task A belongs to this event | 4 | 3 | <-- current branch / mutable state |
| -------- | ------------- | | -------- | ------------- |
| --------- | ------------- |
| Events |
| --------- | ------------- |
| Event ID | Event Version |
| -------- | ------------- |
| 1 | 1 |
| 2 | 1 |
| 3 | 2 |
| -------- | ------------- |
| |
| --------- | ------------- |
| |
| -------- | ------------- | | -------- | ------------- |
| Event ID | Event Version | | Event ID | Event Version |
| -------- | ------------- | | -------- | ------------- |
| 4 | 2 | <-- task A belongs to this event | 4 | 3 | <-- current branch / mutable state
| -------- | ------------- | | -------- | ------------- |
```

T = 2: task A is loaded.
Expand Down