...
- 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 load balancing 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.
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 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
Create load balancer as described above
2. Create launch template
2.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
2.2. Choose latest FlashphonerWebCallServer image
2.3. Choose instance type, key pair for SSH access to an instance, security group
2.4. Set disk size and parameters for instances
2.5. Expand "Advanced details" section. Insert custom update and setup script to "User data" text box
The setup script example to update WCS to latest build and to configure CDN Edge server for WebRTc playback
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
#!/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
#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
# 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
|
2.6. Click "Create launch template"
Launch template will be created
3. Create Auto scaling group
3.1. 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
3.1 Choos launch template, set "Latest" version
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 %
3.4 Choose instance types
3,5. Choose VPC and subnets for instances
3.6. Choose "Classic Load Balancer", set load balancer name created above
3.7. Set the maximum group size
3.8. Select scaling policy by CPU utilization, set target value and instance warming time
3.9. Review group parameters
3.10. Click "Create Auto Scaling group"
Autoscaling group will be created, and one instnce will be launched
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.
...