Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • AMI on the basis of which new instances will be created for scaling out
  • Load Balancer
  • Launch Configuration
  • Auto Scaling Group

Launching AWS Auto Scaling group with classic load

...

balancer from custom AMI

Load balancer with autoscaling deployment from custom AMI can be useful for logn term projects (months and years). In this case, AWS Marketplace image will be more expensive due to hourly payment, therefore it is recommended to buy and activate WCS monthly subscription.

Note that classic load balancer will work till August 2022.

1. Create new AMI

1.1. Launch an instance from a FlashphonerWebCallServer AMI and configure the WCS

...

4.5. Complete the wizard to create the auto scaling group

Launching Application Load Balancer using existing instances

Sometimes, a certain set of instances is already launched and configured (Origin servers group in CDN, for example), and load balancing between those servers should be set up. Use Application Load Balancer to do this.

1. Instances launching

Launch and configure server instances as needed by this manual.

2. Application Load Balancer creation

2.1. In EC2 Console menu, go to "Load balancers - Load balancers" section and click "Create load balancer". Click Create for Application Load Balancer

Image Added

2.2. Enter the balancer name, choose Internet-facing type (supposed by default)

Image Added

2.3. In "Network mapping" section choose a subnets needed

Image Added

2.4. Choose or create security groups as needed

Image Added

Note that a standard WCS ports set should be opened in load balancer security group

Image Added

2.5. In "Listeners and routing" section add Websocket port listener (mandatory) and HTTP port listener (if needed)

Image Added

A target group must be created for every listener, see below.

2.6. Click Create load balancer

Image Added

Load balancer is created

Image Added

3. Websocket listener target group creation

3.1. Choose target type Instances (supposed by default), set group name

Image Added

3.2. Set WCS instance Websocket port (8080), choose subnet and protocol version (HTTP1)

Image Added

3.3. In "Health check" configigure instance health check using HTTP port (8081) and statistics page query /?action=stat

Image Added

Then click Next

Image Added

3.4. At "Register targets" page select instances as needed and click "Include as pending below"

Image Added

Then click "Register pending targets"

Image Added

Target group is created

Image Added

Application load balancer using this group will forward requests to it after at least one of the group instances passes health check.

4. Listener parameters configuration

If Application Load Balancer is created to use in Autoscaling group (see below), HTTPS listener cannot be configured on creation, only HTTP. In this case, listener parameters shoul be changed.

4.1. In EC2 Console section "Load balancers - Load balancers" choose "Listeners" tab for load balancer to configure. Choose Websocket listener and click Edit

Image Added

4.2. Choose HTTPS protocol and set Secure Websocket port (8443 for example)

Image Added

4.3. In "Secure listener settings" section choose SSL certificate to use with domain asigned to load balancer entry point or create a new one. Then click "Save changes"

Image Added

Load balancer listener parameters are changed and will be applied immediately

Image Added

Launching AWS Auto Scaling group with load balancing from AWS Marketplace AMI

Load balancer with autoscaling deployment from AWS Marketplace AMI can be useful for periodic servers group launching, for example, during the event (lasting for hours, days, weeks). In this case, WCS monthly subscription may be more expensive then AWS hourly payment, therefore it is recommeded to use AWS Marketplace AMI.

1

...

Create load balancer as described above

...

. Create launch template

21.1. In EC2 Console go to "Instances - Launch Templates" section and click "Create launch template". Launch template creation wizard will open. Enter template name and description

21.2. Choose latest FlashphonerWebCallServer image

21.3. Choose instance type, key pair for SSH access to an instance, security group

21.4. Set disk size and parameters for instances

21.5. Expand "Advanced details" section. Insert custom update and setup script to "User data" text box

...

Code Block
languagebash
themeRDark
titleEdge setup script
collapsetrue
#!/bin/bash

# Stop WCS before reconfiguring
PID="$(pgrep -f 'com.flashphoner.server.Server' | grep -v bash)"
if [ -n "$PID" ]; then
    service webcallserver stop
fi

# Update WCS to the latest build (optionally, set to false if you don't)
UPDATE=true
if $UPDATE; then
    cd /tmp
    wget --timeout=10 --no-check-certificate https://flashphoner.com/download-wcs5.2-server.tar.gz -O wcs5-server.tar.gz
    if [ $? -eq 0 ]; then
        mkdir -p FlashphonerWebCallServer-5.2-latest && tar xzf wcs5-server.tar.gz -C FlashphonerWebCallServer-5.2-latest --strip-components 1
        cd FlashphonerWebCallServer-5.2-latest
        chmod +x install.sh
        ./install.sh -silent
        cd ..
        rm -rf FlashphonerWebCallServer-5.2-latest wcs5-server.tar.gz
    fi
fi

# Configuration setup
WCS_CONFIG=/usr/local/FlashphonerWebCallServer/conf/flashphoner.properties
JVM_CONFIG=/usr/local/FlashphonerWebCallServer/conf/wcs-core.properties
USERS_CONFIG=/usr/local/FlashphonerWebCallServer/conf/database.yml

#CDN settings
CDN_ROLE=edge
CDN_IP=0.0.0.0
CDN_POINT_OF_ENTRY=172.31.43.82
echo -e "\ncdn_enabled=true" >> $WCS_CONFIG
echo -e "\ncdn_ip=$CDN_IP" >> $WCS_CONFIG
echo -e "\ncdn_role=$CDN_ROLE" >> $WCS_CONFIG
echo -e "\ncdn_point_of_entry=$CDN_POINT_OF_ENTRY" >> $WCS_CONFIG
echo -e "\ncdn_nodes_resolve_ip=false" >> $WCS_CONFIG

# Configure heap settings
HEAP_SIZE=512m
sed -i -e "s/^\(-Xmx\).*\$/\1$HEAP_SIZE/" $JVM_CONFIG

# Disable demo user (optionally, set to true if you want to disable)
DISABLE_DEMO=false
if $DISABLE_DEMO; then
 if grep "demo:" $USERS_CONFIG > /dev/null 2>&1; then
  sed -i -e "/demo:/s/active:\ true/active:\ false/" $USERS_CONFIG
 fi
fi

# Start WCS after reconfiguring
PID="$(pgrep -f 'com.flashphoner.server.Server' | grep -v bash)"
if [ -n "$PID" ]; then
    service webcallserver restart
else
    service webcallserver start
fi

# Disable internal firewall, ports are allowed/blocked on security group level
iptables -F

21.6. Click "Create launch template"

...

Launch template will be created

...

2. Create Auto scaling group

32.1.  In In EC2 Console go to "Instances - Auto Scaling Groups" section and click "Create an Auto Scaling Group". Autoscaling group creation wizard will open. Enter group name

Image Modified

32.1 Choos 2 Choose launch template, set "Latest" version

Image Modified

2.3. 2. Set instances distributon percentage (on demand/spot). By default 70 % on demand will be set, it is recommended to raise this value to 100 %

Image Modified

32.4 Choose instance types

Image Modified

32,5. Choose VPC and subnets for instances

Image Modified

32.6.Choose "Attach to a new load balancer"

Image Added

2.7. Choose "Classic Load Balancer", set load balancer name created above

Image Removed

3.7Application Load balancer" type, set the name, choose Internet-facing, set availability zones and corresponding subnets

Image Added

2.8. In "Listeners and routing" section set Websocket port (8080), choose "Create a target group" and set the target group name to be created

Image Added

Then click Next

Image Added

2.9. Set the maximum group size

Image Modified

32.810. Select scaling policy by CPU utilization, set target value and instance warming time

Image Modified

32.911. Review group parameters

Image Modified

32.1012. Click "Create Auto Scaling group"

Image Modified

Autoscaling group will be created, and one instnce will be launched

Image Modified

2.13. Configure load balancer listener as described above

Testing

If load balancer has no running instances, then a new instance will be started when an auto scaling group receiving traffic from the load balancer is created. More instances will be started in case scaling is triggered. (For testing purposes, streaming with transcoding – e.g., streaming RTMP to auto created mixer – can be used to load server CPU.) All the started instances will be auto added to the corresponding load balancer.

...