Skip to content

Commit 9355a3e

Browse files
aldy505markstory
andauthored
docs(self-hosted): provide guide for scaling up taskbroker and taskworker (#15136)
Insights from my own findings & from Mark Story! --------- Co-authored-by: Mark Story <[email protected]>
1 parent 89bc33e commit 9355a3e

File tree

1 file changed

+73
-4
lines changed

1 file changed

+73
-4
lines changed

develop-docs/self-hosted/tasks.mdx

Lines changed: 73 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ Brokers and workers can be scaled horizontally to increase parallelism.
2525

2626
By default, self-hosted installs come with a single broker & worker replica. You
2727
can increase processing capacity by adding more concurrency to the single worker
28-
(via the `--concurrency` option on the worker), or by adding additional worker, and broker
29-
replicas. It is not recommended to go above 24 worker replicas per broker as
30-
broker performance can degrade with higher worker counts.
28+
(via the `--concurrency` option on the worker), or by adding additional worker,
29+
and broker replicas. It is not recommended to go above 24 worker replicas
30+
per broker as broker performance can degrade with higher worker counts.
3131

3232
If your deployment requires additional processing capacity, you can add
3333
additional broker replicas and use CLI options to inform the workers of the
@@ -40,7 +40,76 @@ sentry run taskworker --rpc-host-list=sentry-broker-default-0:50051,sentry-broke
4040
Workers use client-side loadbalancing to distribute load across the brokers they
4141
have been assigned to.
4242

43-
## Running multiple brokers
43+
If you only want to scale `taskworker` replicas and you have a single `taskbroker`,
44+
you can easily increase it (up to 24 replicas) by modifying your `docker-compose.override.yml`
45+
file:
46+
47+
```yaml
48+
services:
49+
taskworker:
50+
deploy:
51+
replicas: 5
52+
```
53+
54+
This will spawn 5 replicas of the `taskworker` service. Bear in mind that although
55+
the processing capacity is increased, you will need to monitor and scale your
56+
system resources (CPU and RAM) accordingly.
57+
58+
## Scaling brokers
59+
60+
If you have reached the maximum number of `taskworker` replicas, you can scale
61+
your `taskbroker` replicas. First, you need to increase the number of partitions
62+
on "taskworker" topic in Kafka, the number of partitions should be evenly divisible by
63+
the number of `taskbroker` replicas that you're planning to scale to.
64+
Then due to the limited capability of Docker Compose, you will need to manually
65+
scale your `taskbroker` replicas. You can do this by adding more container
66+
declarations to your `docker-compose.override.yml` file:
67+
68+
```yaml
69+
services:
70+
taskbroker-beta:
71+
restart: "unless-stopped"
72+
image: "$TASKBROKER_IMAGE"
73+
environment:
74+
TASKBROKER_KAFKA_CLUSTER: "kafka:9092"
75+
TASKBROKER_KAFKA_DEADLETTER_CLUSTER: "kafka:9092"
76+
TASKBROKER_DB_PATH: "/opt/sqlite/taskbroker-activations-beta.sqlite"
77+
volumes:
78+
- sentry-taskbroker:/opt/sqlite
79+
depends_on:
80+
- kafka
81+
taskbroker-charlie:
82+
restart: "unless-stopped"
83+
image: "$TASKBROKER_IMAGE"
84+
environment:
85+
TASKBROKER_KAFKA_CLUSTER: "kafka:9092"
86+
TASKBROKER_KAFKA_DEADLETTER_CLUSTER: "kafka:9092"
87+
TASKBROKER_DB_PATH: "/opt/sqlite/taskbroker-activations-charlie.sqlite"
88+
volumes:
89+
- sentry-taskbroker:/opt/sqlite
90+
depends_on:
91+
- kafka
92+
```
93+
94+
Note that each `taskbroker` replica needs their own SQLite database per replica, to prevent
95+
issues contention and locks between replicas.
96+
97+
Finally, you need to modify `taskworker` command to have `rpc-host-list` pointing
98+
to the new brokers:
99+
100+
```yaml
101+
taskworker:
102+
<<: *sentry_defaults
103+
command: run taskworker --concurrency=4 --rpc-host-list=taskbroker:50051,taskbroker-beta:50051,taskbroker-charlie:50051 --health-check-file-path=/tmp/health.txt
104+
healthcheck:
105+
<<: *file_healthcheck_defaults
106+
```
107+
108+
If you are running on Kubernetes, you can utilize `--rpc-host` and `--num-brokers`
109+
instead if you are using StatefulSet. Otherwise, you can use `--rpc-host-list`
110+
if you have a different host name pattern for the brokers.
111+
112+
## Isolate Workload Separation
44113

45114
In higher throughput installations, you may also want to isolate task workloads
46115
from each other to ensure timely processing of lower volume tasks. For example,

0 commit comments

Comments
 (0)