Skip to content

A free and open source instant messaging and VoIP chat app built for friends, groups, and communities.

TypeScript fluxerfluxerapp

fix(gateway): clamp the derived BEAM scheduler count (#2243)

Hampus8c3e3285f765
diff --git a/deploy/self-hosting/.env.example b/deploy/self-hosting/.env.example
index a947a4577..3944df993 100644
--- a/deploy/self-hosting/.env.example
+++ b/deploy/self-hosting/.env.example
@@ -106,3 +106,10 @@ FLUXER_DISCOVERY_ENABLED=true
# durable state elsewhere.
#FLUXER_VALKEY_MAXMEMORY=192mb
#FLUXER_VALKEY_MAXMEMORY_POLICY=noeviction
+
+# The gateway derives its BEAM scheduler count from the container CPU quota,
+# clamped to this range. The floor matters: a single scheduler lets one blocking
+# operation stall every websocket on the node. The ceiling stops a large host
+# from starting far more schedulers than the container can actually use.
+#FLUXER_ERLANG_SCHEDULERS_MIN=2
+#FLUXER_ERLANG_SCHEDULERS_MAX=16
diff --git a/fluxer_gateway/scripts/docker_entrypoint.sh b/fluxer_gateway/scripts/docker_entrypoint.sh
index 60469f615..bc9de4c1f 100755
--- a/fluxer_gateway/scripts/docker_entrypoint.sh
+++ b/fluxer_gateway/scripts/docker_entrypoint.sh
@@ -37,12 +37,27 @@ available_cpu_count() {
fi
}
+clamp_int() {
+ value="$1"
+ min="$2"
+ max="$3"
+ if [ "$value" -lt "$min" ]; then
+ value="$min"
+ fi
+ if [ "$value" -gt "$max" ]; then
+ value="$max"
+ fi
+ echo "$value"
+}
+
+: "${FLUXER_ERLANG_SCHEDULERS_MIN:=2}"
+: "${FLUXER_ERLANG_SCHEDULERS_MAX:=16}"
: "${FLUXER_ERLANG_NODE_NAME:[email protected]}"
: "${FLUXER_ERLANG_COOKIE:=fluxer_gateway_dev_cookie}"
: "${FLUXER_ERLANG_DIST_PORT:=8081}"
if ! is_positive_int "${FLUXER_ERLANG_SCHEDULERS:-}"; then
- FLUXER_ERLANG_SCHEDULERS="$(available_cpu_count)"
+ FLUXER_ERLANG_SCHEDULERS="$(clamp_int "$(available_cpu_count)" "$FLUXER_ERLANG_SCHEDULERS_MIN" "$FLUXER_ERLANG_SCHEDULERS_MAX")"
fi
if ! is_positive_int "${FLUXER_ERLANG_DIRTY_CPU_SCHEDULERS:-}"; then