Cloud Deployment

AMS on Azure Deployment

General Steps Deploy on Azure Portal

This guide describes how to install and set up Ant Media Server on a Microsoft Azure Marketplace Ubuntu 16.04 virtual machine instance. This tutorial assumes that you have an Azure account, or a trial account.

Step 1: Create a Virtual Machine

Firstly, click Create a resource in Azure Dashboard.

Create a resource in Azure Dashboard

After clicking on Create a resouce, you will see the new Marketplace page. Please write “Ant Media Server” to the search side.

Azure Marketplace listing Ant Media Server

Choose one of Ant Media Server Community Edition or Enterprise Edition.

Azure Marketplace listing Ant Media Server

Tip

Community Edition and Enterprise Edition comparison chart is here.

Step 2: Customize Virtual Machine

Part 1 – “Basics” in Create a Virtual Machine

Basics section in Azure Marketplace Virtual Machine

In Subscription, Azure default payment method is Pay-As-You-Go. More details for see this link.

In Resource group, specify the resource group. To select an existing resource group, click Use existing, and then click the arrow in the list box to reveal existing resource groups. To create a new resource group, click Create new, and then type a name for it in the list box. For details, see Manage resource groups.

In Virtual machine name, enter a name for your virtual machine. (“name must be 1-64 characters long and it cannot contain non-ASCII and special characters.”)

In Region, select the region where the virtual machine instance will be located. It’s best to select a location that has the lowest latency to a camera or encoder that’s delivering a live stream to Ant Medai Server.

In Image, will see your selected image.

In VM disk type, choose a disk type. Azure solid state disks (SSD) are backed by solid state drives and offer consistent, low latency performance. They provide the best balance between price and performance and are ideal for I/O-intensive applications and production workloads.

In User name, type the name of the account that you’ll use to administer the virtual machine (you can’t use root for the user name). Then under Authentication type, click SSH public key and copy and paste an OpenSSH public key that will be used to authenticate the account user name.

Tip

Note: You can generate an OpenSSH public key with tools like ssh-keygen on Linux and OS X or PuTTYgen on Windows. For details, see Create and use an SSH public-private key pair for Linux VMs in Azure.

Part 2 – “Disks” in Create a Virtual Machine

Disks section in Azure Marketplace Virtual Machine

In OS disk type, Effective at input speeds I/O. Premium SSD disks offer high-performance, low-latency disk support for I/O-intensive applications and production workloads.

Standard SSD Disks are a cost effective storage option optimized for workloads that need consistent performance at lower IOPS levels.

Use Standard HDD disks for Dev/Test scenarios and less critical workloads at lowest cost.

Tip

We recommend Premium SSD for high I/O.

Part 3 – “Networking” in Create a Virtual Machine

Networking section in Azure Marketplace Virtual Machine

In Virtual Network, currently selected subscription and location are listed. If you choose to create a new virtual network, it will be created in the same subscription, location, and resource group as the storage account. Virtual networks in a different subscription, and/or paired failover location, may be specified after storage account creation.

In Subnet, listed in default value of your Virtual Network.

In Public IP, communicate with Virtual Machine from outside the Virtual Network.

In Configure network security group, the most important configuration is here. Here is the TCP and UDP port, inbound and outbound permissions are configured. If you change port setting in Ant Media Server, you need to change “Configure network security group”. Ant Media Server default port values listed in below.

Warning

The following ports to the Inbound list in Ant Media Server:

Part 4 – “Management” in Create Virtual Machine

Management section in Azure Marketplace Virtual Machine

Configure monitoring and management options for your Virtual Machine

Part 5 – “Guest Config” in Create Virtual Machine

Guest Config section in Azure Marketplace Virtual Machine

Here is Extensions and Cloud Init options.

Extension means using in server applications like Acronis Backup.

Ant Media Server image doesn’t support cloud init.

Part 6 – “Tags” in Create Virtual Machine

Tags Config section in Azure Marketplace Virtual Machine

Tags are name/value pairs that enable you to categorize resources and view consolidated billing by applying the same tag to multiple resources and resource groups.

Part 7 – “Review + Create” in Create Virtual Machine

Review + Create section in Azure Marketplace Virtual Machine

Here you will see the settings you have made in other sections. Checking all the settings you can create the virtual machine.

After creating the instance, wait for installation and reach management console from the URL: http://<Server_IP_Address>:5080 .

If you have any question, contact us from the website.I hope this tutorial has been useful to you.

AMS Cluster On AWS

General View of AMS Cluster

AMS Cluster Overview

Step 0: VPC Settings In AWS

  • Signup and Login to AWS
  • In AWS create VPC (Virtual Private Cloud).
  • Create 3 subnet under VPC with names subnet-1, subnet-2 and subnet-3.

Note

VPC and 3 subnets are available for new user.

Tip

You can look at AWS Documentation for details about VPCs.

Step 1: Create Security Groups

  • Get IPv4 CIDR using VPC from VPC list. It is like as 172.31.0.0/16. Let say it VPC_CIDR.
  • Create a security group with name Mongo-Security and inbound settings:
  • Type: SSH, Protocol: TCP, Port:22, Source: Anywhere
  • Type: Custom TCP, Protocol: TCP, Port:27017, Source: VPC_CIDR
  • Create a security group with name AMS-Security and inbound settings:
  • Type: SSH, Protocol: TCP, Port:22, Source: Anywhere
  • Type:All Traffic, Source: VPC_CIDR (Actually this is enough)
  • Create a security group with name WebRTC-Security and inbound settings:
  • Type: Custom UDP, Protocol: UDP, Port:X-Y, Source: Anywhere
  • Create a security group with name LB-Security and inbound settings:
  • Type: Custom TCP, Protocol: TCP, Port:5080, Source: Anywhere (for unsecure connection)
  • Type: Custom TCP, Protocol: TCP, Port:5443, Source: Anywhere (for secure connection SSL)
  • Type: Custom HTTP, Protocol: TCP, Port:80, Source: Anywhere (for unsecure connection)
  • Type: Custom HTTPS, Protocol: TCP, Port:443, Source: Anywhere (for secure connection SSL)
  • Type: Custom TCP, Protocol: TCP, Port:1935, Source: Anywhere

Tip

You can look at AWS Documentation for details about Security Groups.

Step 2: Load Balancer Settings

HTTP Load Balancing

  • You should create Application Load Balancer for HTTP requests and websocket. You must define Listener and corresponding Target Group for each port.
  • Cirstly create a Target Groups with names Origin5080, protocol HTTP and port 5080
  • Create a Target Groups with names Egde5080, protocol HTTP and port 5080
  • After creation, select the group, click set atributes and then enable stickeness.

Tip

You can look at AWS Documentation for details about Target Groups.

  • Set Network Load Balancer name as OriginHTTPLB
  • For origins add Listener for HTTPS:443 (or if you don’t need SSL then HTTP:80)
  • For edges add Listeners for HTTPS:5443 (or if you don’t need SSL then HTTP:5080)
  • Choose subnet-1 and subnet-3 as Availability Zones
  • Fill the SSL Certificate informations. (if you don’t need SSL then skip this step)
  • Select Origin5080 as Target Group.
  • Select LB-Security as Security Group.
  • Finish the creation.

Warning

We have one more step. Both listeners are forwarded to Origin5080. We forward 5443 (or 5080) listener to Edge5080. Select created load balancer under Listeners tab edit the 5443 (or 5080) listener as forward to Edge5080.

Before:

AMS Cluster LB before

After:

AMS Cluster LB after

Tip

You can look at AWS Documentation for details about Application Load Balancers.

Step 3: Create and Run Mongo Instance

  • Create an EC2 instance with AMS Mongo AMI
  • Select subnet-3 as subnet
  • Under Details write the following in User Data as text:
sudo service mongod start
  • Select Mongo-Security as security group
  • After creation note the private IP of instance. Let say it MongoIP.
  • Finish the creation.

Tip

You can look at AWS Documentation and this for details about launching an instance using AMI.

Step 4: Create Auto Scaling Launch Configuration

  • Select AMS AMI as image
  • Set name as AMS-Cluster
  • Under Details write the followings in User Data as text:
#!/bin/bash
cd /usr/local/antmedia
./change_server_mode.sh cluster <MongoIP>
Auto Scaling Launch Configuration
  • Select AMS-Security and WebRTC-Security as security group
  • Finish the creation.

Warning

Here we create one Launch Configuration for both origins and edges. But normally instances for origins and edges may be different. Origins should be more powerful. So we need to create seperate Launch Configurations. You can create one then copy and edit for the second.

Tip

You can look at AWS Documentation for details about Auto Scaling Launch Configuration.

Step 5: Create Auto Scaling Group

  • Select AMS-Cluster as launch configuration
  • Set name as Origins
  • Select subnet-1 as subnet
  • Under Advanced Details enable Load Balancing and select Origin5080 as target group.
  • Select min and max numbers of nodes
  • Click Scale the Auto Scaling group using step or simple scaling policies link - Under Increase Group Size, click add new alarm and define policy as add an instance after CPU > 80. (uncheck “Send a notification to”) - Under Decrease Group Size, click add new alarm and define policy as remove an instance after CPU < 10. (uncheck “Send a notification to”)
Auto Scaling Group
  • Repeat steps for Edges
  • After creation of Auto Scaling Group, AMS instances start.

Tip

You can look at AWS Documentation for details about Auto Scaling Group.

Step 6: Test

  • Login Management console over https://<LoadBalancerDNS>

    (or http://<LoadBalancerDNS>)

  • Check the cluster page and show nodes

  • Publish a stream to Origin over https://<LoadBalancerDNS>/WebRTCAppEE

    (or http://<LoadBalancerDNS>/WebRTCAppEE)

  • Play the stream from Edge over https://<LoadBalancerDNS>:5443/WebRTCAppEE/player.html

    (or http://<LoadBalancerDNS>:5080/WebRTCAppEE/player.html)

RTMP Load Balancing (Optional)

  • If you want to use RTMP publishing, you should create Network Load Balancer for RTMP publishers. You must define a Listener and corresponding Target Group for each port.
  • Firstly create a Target Groups with name Origin1935, protocol TCP and port 1935
  • Set Network Load Balancer name as OriginRTMPLB
  • Add Listeners for TCP:1935
  • Choose subnet-1 as Availability Zones
  • Select Origin1935 as Target Group.
  • Finish the creation

AMS Cluster On Azure

This document is a guide for setting up clustering in Azure platform.

Requirements:
Having an Azure account and a ready AntMedia Server Image.

Architecture of cluster setup could be found here.
Introduction to clustering with AntMedia Server could be found here.

Step 1: Create a Virtual network

Firstly, we need to create a virtual network named antmediaserver, and then we will add origin-subnet and edge-subnet as described in this doc.

Step 2: Create a Public IP

Create a static public IP address described as here. Name it antmediaserver-ip.

Step 3: Create a Storage Account

Create a storage account as described here. Name it mediastorage.

Step 4: Create a MongoDB Virtual Machine

Create a virtual machine with MongoDB as described here.

Step 5: Create a Virtual Machine for AntMedia

  1. In All Resources, select your AntMedia image and click Create VM in the upper bar.
  2. In Basic tab
  • Enter virtual machine name.
  • Enter your SSH public key if the authentication type is SSH public key.
  • Select a VM size.
  1. Skip Disks tab.
  2. In Networking tab:
  • Select antmediaserver as virtual network.
  • Select edge-subnet as a Subnet.
  • Select the antmediaserver-ip public ip address which is created before.
  1. In Management tab:
  • Select your diagnotics Storage account which is mediastorage.
  1. Skip other tabs and click Create and create a virtual machine.

Step 6: Setup AntMedia in VM

Warning

Be aware that it may take some time for the new VM to start up.

  1. In All resources, click the VM that you created and note the public IP address.
  2. We need to open port 22 for connecting with ssh. In networking section, click Add inbound port. Enter 22 for Destinations port ranges. Select Any as protocol. Enter 100 as Priorty. Give a name such as Port_22.
  3. Open port 5080 similar to opening the port 22, but select TCP as protocol and priority as 200.
  4. Use ssh and connect to this VM.
  5. Download the AntMedia Server zip file and setup using this script.
  6. Run this script.
sudo ./change_server_mode.sh cluster <MONGO_SERVER_IP>

where MONGO_SERVER_IP is the private IP and can be learnt from MongoDB server in All Resources. Now server will start in cluster mode.

Step 7: Create Scale Sets

  1. We need to setup scale sets. We need an image for this. So go to VM that you created and click Capture. Enter a name and select the resource group that you created before.
  2. Click Create a Resource which is on the top left and search for virtual machine scale set. Select virtual machine scale set in the list and click create.
  3. Create edgescale scale set:
  • Enter a scale set name “edgescale”.
  • Set Availability zone to None.
  • Set username.
  • Set SSH public key.
  • Set instance count to minimum number that you need.
  • Select a VM size.
  • Enable AutoScale with min and max instance numbers.
  • Select Application Gateway as load balancer.
  • Select edge-subnet as subnet which is created before.
  • Enable public IP address per instance.
  • Click create.
  1. Create a scale set for origin:
  • Enter a scale set name “originscale”
  • Click browse all images and in my items tab select the image that you created.
  • Set username.
  • Set SSH public key.
  • Set instance count to 1.
  • Select a VM size.
  • Enable AutoScale with min and max instance numbers.
  • Select Application Gateway as load balancer.
  • Select origin-subnet as subnet which is created before.
  • Enable public IP address per instance.
  • Click create.

Step 8: Create Application Gateway

Create an Application Gateway described as here. Application Gateway will be the load balancer.

  1. Click Listeners and create listeners as seen below:
_images/azure_listeners.png
  1. Click Frontend IP configuration and create public IP configuration as seen below:
_images/azure_publicip.png
  1. Click HTTP Settings and add a new one as seen below:
_images/azure_httpsettings.png
  1. Click Rules.
  2. Create http_5080_edge as seen below:
_images/azure_rule_http_5080_edge.png
  1. Create http_80_origin as seen below:
_images/azure_rule_http_80_origin.png
  1. Create https_5443_edge as seen below:
_images/azure_rule_https_5443_edge.png
  1. Create https_443_origin as seen below:
_images/azure_rule_https_443_origin.png

This completes the setup.