Autoscaling considerations for CDN HLS Viewing

Hi,

I am having origin and edge servers behind respective load balancers (AWS LB). Using CDN edge servers, I am playing the stream using HLS.

I done a WebRTC publish load test by following this link https://docs.flashphoner.com/display/WCS52EN/Load+testing+using+WebRTC+pulling. I can able to see the rise in CPU utilization in origin servers.

I want to know is there any built-in functionality in WCS server to load test HLS viewers. I tried with jmeter and not seeing much rise in CPU utilization in edge servers.

So,
1) Is the HLS streaming doesn't utilize much CPU or how it does work when multiple users (let's say 100) connect to the stream in parallel?
2) Is the segments gets re-used in CDN for each users or it is generated for each users?
3) For Origin server Autoscaling, I can use CPU utilization as a threshold. For edge servers (HLS play), what metric has to be considered as a threshold value?
 

Max

Administrator
Staff member
Good day.
I want to know is there any built-in functionality in WCS server to load test HLS viewers.
There's no such function out of the box, but you can use a script like this
Code:
#!/bin/bash

# Display HTTP response code
result() {
    if [[ -n $3 ]]; then
            echo $1-$2
            echo $3
    else
        exit 1
    fi
}

streams=()
profiles=()

STREAMS_CNT=$1
SUBSCRIBERS_CNT=$2
STREAMS_PAUSE=$3

# Initialize maximum simultaneous subscribers count
if [[ "$SUBSCRIBERS_CNT" == "" ]]; then
    SUBSCRIBERS_CNT=40
fi
# Initialize pause between GET queries
if [[ "$STREAMS_PAUSE" == "" ]]; then
    STREAMS_PAUSE=0
fi
# Initialise maximum streams count
if [[ "$STREAMS_CNT" == "" ]]; then
    STREAMS_CNT=100
fi


# Fill transcoding profiles list if needed
PROFILES="240p,360p,480p"

#Form streams list
STREAMS=""
for ((i = 0; i < $STREAMS_CNT; i++))
do
    if [ -z $STREAMS ]; then
        STREAMS="test_$i"
    else
        STREAMS="$STREAMS,test_$i"
    fi
done

# Set the server URL
URL=http://localhost:8082

# Form streams and profiles arrays
IFS="," read -ra streams <<<"$STREAMS"
if [[ "$PROFILES" != "" ]]; then
    IFS="," read -ra profiles <<<"$PROFILES"
fi

# Script will worl until Ctrl+C interruption
while true
do
for ((i = 0; i < $SUBSCRIBERS_CNT; i++))
do
    # Requesting playlist for every stream
    for stream in ${streams[@]}; do
        # ...and for every profile if needed
        if [[ "$PROFILES" != "" ]]; then
            for profile in ${profiles[@]}; do
                (result $stream $profile $(curl --insecure -s -i -o /dev/null -w '%{http_code}' $URL/$stream-$profile/$stream-$profile.m3u8)) &
                sleep $STREAMS_PAUSE
            done
        else
            (result $stream "original" $(curl --insecure -s -i -o /dev/null -w '%{http_code}' $URL/$stream/$stream.m3u8)) &
        fi
        # Wait between streams playlist queries
        sleep $STREAMS_PAUSE
    done
    # Wait between subscribers 
    sleep $STREAMS_PAUSE
done
# Wait every subs
sleep 5
done
# Kill orhaned requests
pkill curl
Before running the test, you should publish streams with names test_0-test_XX (for example, 20) to Origin server. Then, launch the script on Edge, for example
Code:
hls_test 20 40 5
1) Is the HLS streaming doesn't utilize much CPU or how it does work when multiple users (let's say 100) connect to the stream in parallel?
2) Is the segments gets re-used in CDN for each users or it is generated for each users?
If there's no stream transcoding on Edge server, HLS streaming should utilize less CPU comparing to Transcoder or Origin.
HLS segments are cut on Edge server per every stream with HLS subscribers. All subscribers receive the same segments for the stream, there's no segments duplication for each user.
In latest builds, HLS playlists are sent to subscribers from memory and HLS segments from disk. To improve perfomance, you can enable segments sending from memory too
Code:
hls_store_segment_in_memory=true
but you should allocate enough Java heap memory (1/2 of servers RAM recommended).
3) For Origin server Autoscaling, I can use CPU utilization as a threshold. For edge servers (HLS play), what metric has to be considered as a threshold value?
CPU utilization metric is suitable for most cases. There are some WCS specific metrics available at statistics page, but they can't be used in AWS LB settings.
 
Top