936363b310
We currently use a simple producer round-robin algorithm to distribute elements between mediasoup workers. This works for most scenarios but fails in some edge cases, such as: - 1-to-N scenarios where N >= ~600-800 (sample number, varies by single-core performance). This is due to subscribers being pinned to a producer's worker. - Poor distribution results from round-robin. Enable the following new features in bbb-webrtc-sfu via after-install by default: - `mediasoup.workerBalancing.strategy: least-loaded`: Replaces round-robin with load scoring. Workers are selected based on which is least loaded. - `mediasoup.enableWorkerTransposing: true`: Allows media streams to be bridged between workers through internal RTP pipes. This, along with a per-worker stream limit, enables seamless offloading of streams between workers (whether publishers or subscribers). The per-worker stream limit is still under review. These changes should address the issues mentioned. They are enabled via after-install because the SFU version is shared with previous BBB versions where these features are not desirable yet.
77 lines
2.8 KiB
Bash
Executable File
77 lines
2.8 KiB
Bash
Executable File
#!/bin/bash -ex
|
|
|
|
source /etc/lsb-release
|
|
|
|
case "$1" in
|
|
configure|upgrade|1|2)
|
|
TARGET=/usr/local/bigbluebutton/bbb-webrtc-sfu/config/default.yml
|
|
|
|
cp /usr/local/bigbluebutton/bbb-webrtc-sfu/config/default.example.yml $TARGET
|
|
chown bigbluebutton:bigbluebutton $TARGET
|
|
|
|
# Set mediasoup IPs
|
|
yq e -i ".mediasoup.webrtc.listenIps[0].announcedIp = \"$IP\"" $TARGET
|
|
yq e -i ".mediasoup.plainRtp.listenIp.announcedIp = \"$IP\"" $TARGET
|
|
# mediasoup.workerBalancing: defines the strategy to distribute mediasoup
|
|
# elements (transports, producers, consumers) among workers.
|
|
yq e -i '.mediasoup.workerBalancing.strategy = "least-loaded"' $TARGET
|
|
# mediasoup.enableWorkerTransposing: whether to enable worker transposing
|
|
# (ie: the ability to move a media stream from one worker to another).
|
|
yq e -i '.mediasoup.enableWorkerTransposing = true' $TARGET
|
|
|
|
FREESWITCH_IP=$(xmlstarlet sel -t -v '//X-PRE-PROCESS[@cmd="set" and starts-with(@data, "local_ip_v4=")]/@data' /opt/freeswitch/conf/vars.xml | sed 's/local_ip_v4=//g')
|
|
if [ "$FREESWITCH_IP" != "" ]; then
|
|
yq e -i ".freeswitch.ip = \"$FREESWITCH_IP\"" $TARGET
|
|
yq e -i ".freeswitch.sip_ip = \"$IP\"" $TARGET
|
|
else
|
|
# Looks like the FreeSWITCH package is being installed, let's fall back to the default value
|
|
yq e -i ".freeswitch.ip = \"$IP\"" $TARGET
|
|
if [ "$DISTRIB_CODENAME" == "focal" ]; then
|
|
yq e -i ".freeswitch.sip_ip = \"$IP\"" $TARGET
|
|
fi
|
|
fi
|
|
|
|
cd /usr/local/bigbluebutton/bbb-webrtc-sfu
|
|
mkdir -p node_modules
|
|
|
|
mkdir -p /var/log/bbb-webrtc-sfu/
|
|
touch /var/log/bbb-webrtc-sfu/bbb-webrtc-sfu.log
|
|
|
|
yq e -i '.recordWebcams = true' $TARGET
|
|
# Set bbb-webrtc-recorder as the default recordingAdapter
|
|
yq e -i '.recordingAdapter = "bbb-webrtc-recorder"' $TARGET
|
|
# Do not configure any Kurento instances - BBB >= 2.8 doesn't provide Kurento by default
|
|
yq e -i '.kurento = []' $TARGET
|
|
|
|
echo "Resetting mcs-address from localhost to 127.0.0.1"
|
|
yq e -i '.mcs-address = "127.0.0.1"' $TARGET
|
|
|
|
if id bigbluebutton > /dev/null 2>&1; then
|
|
chown -R bigbluebutton:bigbluebutton /usr/local/bigbluebutton/bbb-webrtc-sfu /var/log/bbb-webrtc-sfu/
|
|
else
|
|
echo "#"
|
|
echo "# Warning: Unable to assign ownership of bigbluebutton to sfu files"
|
|
echo "#"
|
|
fi
|
|
|
|
# Creates the mediasoup raw media file dir if needed
|
|
if [ ! -d /var/mediasoup ]; then
|
|
mkdir -p /var/mediasoup
|
|
fi
|
|
|
|
chmod 644 $TARGET
|
|
chown bigbluebutton:bigbluebutton $TARGET
|
|
|
|
reloadService nginx
|
|
startService bbb-webrtc-sfu || echo "bbb-webrtc-sfu could not be registered or started"
|
|
;;
|
|
|
|
abort-upgrade|abort-remove|abort-deconfigure)
|
|
;;
|
|
|
|
*)
|
|
echo "postinst called with unknown argument \`$1'" >&2
|
|
exit 1
|
|
;;
|
|
esac
|