Skip to content

How to Setup Ant Media Server Clustering on Azure

muratugureminoglu edited this page Nov 1, 2020 · 42 revisions

In this guide, I will explain how to setup Ant Media Server Clustering on Azure. When your load is high, one server instance is not enough for you and you can handle that load with a clustering solution.

For streaming applications, you will need a clustering solution when you have high numbers of publishers and viewers. Especially when you require ultra-low latency and adaptive bitrate because they need more processing power. Ultra-low latency is achieved by WebRTC and it is a CPU intensive protocol. Adaptive bitrating is downgrading video quality in bad networks if needed. It is also CPU intensive because there is video conversion. Luckily, Ant Media Server Enterprise Edition supports clustering, so that you can handle the high load in your streaming applications.

Requirements: To set up media server, Having an Azure account and a ready AntMedia Server Image are needed.

The architecture of the cluster setup could be found here. Introduction to clustering with AntMedia Server could be found here.

Step 1: Create a Resource Group

Image

Image

Image

Step 2: Create a Virtual Network

We need to create a virtual network named antmedia-cluster-virtual-network, and then we will add gateway-subnet, origin-subnet and edge-subnet as described in this doc.

Click Create a Resource in the portal which is on the upper left. Enter Virtual network in the Search the Marketplace box at the top of the New pane that appears. Click Virtual network when it appears in the search results.

Image

Select Classic in the Select a deployment model box in the Virtual Network pane that appears, then click Create.

Image

Daha once olusturdugumuz resource grubu secip, name alanina antmedia-clustur-virtual-network yazip "Next: IP Address" butonuna tiklayin.

Image

Add subnet butonuna tiklayip antmedia-origin-subnet, antmedia-edge-subnet ve antmedia-gw-subnet lerini asagidaki sekildeki gibi olusturun.

Image

Olusturdugunuz subnet asagidaki gibi gozukecektir. Her sey tamamsa "Review + create" butonuna tiklayip Virtual Networkunuzu olusturun.

Image

Create butonuna tiklanayarak islem tamamlanir.

Image

Step 3: Create a MongoDB Virtual Machine

Click Virtual Machines on the left bar and then click +Add:

Image

Enter the following values and click next:

Image

Enter the following values and click next:

Image

Virtual Network kismindan olusturdugumuz Virtual Networku secin, Nic network security Group 'dan Advanced 'i secin ve Create New e tiklayin.

Image

Acilan pencerede Add an inbound Rule tiklayin ve asagidaki gibi inbound security rule ekleyin.

Image

Enter the following values and click next:

Image

Custom data alanina asagidaki satirlari ekleyin ve "Review + Create" butonuna tiklayip MongoDB instnacesini olusturun.

#!/bin/bash
wget -qO - https://www.mongodb.org/static/pgp/server-4.2.asc | sudo apt-key add -
echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu `lsb_release -cs`/mongodb-org/4.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.2.list
sudo apt-get update
sudo apt-get install -y mongodb-org
sed -i 's/bindIp:.*/bindIp: 0.0.0.0/g' /etc/mongod.conf
systemctl restart mongod

Image

Image

Step 4: Create Application Gateway

Click Create a Resource in the portal which is on the upper left. Enter Application Gateway in the Search the Marketplace box at the top of the New pane that appears. Click Application Gateway when it appears in the search results.

Image

Select Classic in the Select a deployment model box in the Application Gateway pane that appears, then click Create.

Image

Resource Group, Application Gateway Name, Region ve Virtual Network ayarlarini asagidaki gibi giriniz ve "Next: Frontends" e tiklayin.

Image

Add New butonuna tiklayip asagidaki gibi girin ve "Next: Backends" 'e tiklayin.

Image

Add a Backend pool 'a tiklayip ekram goruntusundeki gibi hem origin hem de Edge icin poollar olusturun ve "Next: Configuration" 'a tiklayin.

Image

Add a routing rule 'e atiklayin.

Image

Ekran goruntundeki gibi alanlari doldurup "Backend targets" 'i tiklayin.

Image

Backend target "Edge" poolunu secin ve HTTP settings icon Add new 'e tiklayin.

Image

Asagidaki gibi doldurun. Bu ayar hem origin hem de origin icin olacaktir.

Image

Ayarlariniz asagidaki gibiyse HTTP istekler icin Edge yapilandirilmasi bitmistir.

Image

Tekrar "Add a routing rule" 'e tiklayip Origin icin HTTP ayarlarini yapalim. Asagidaki gibi ayarlari yapip "Backend target" tiklayin.

Image

Backend target olarak Origin poolunu secin ve HTTP settings olarakta onceden olusturdugumuz "BackendHttpSettings" i secin.

Image

Simdi sirada Origin icin HTTPS isteklerini yonlendirmeye geldi. Bunun icin asagidaki gibi ayarlari yapin. cluster.antmedia.io.pfx sertifikasi icin bu linki kullanabilirsiniz.

Image

Backend target olarak Origin ve HTTP Settings olarak "BackendHttpSetting" secin.

Image

Ayni sekilde Edge icin 5443 icin yapilandirmayi asagidaki gibi yapin.

Image

Backend target olarak Edge ve HTTP Settings olarak "BackendHttpSetting" secin.

Image

Tam olarak application-gateway ayarlari asagidaki gibi gozukecektir. Her sey yolundaysa "Next:Tags" tiklayin.

Image

Son olarak "Create" basarak kurulumu tamamlayin.

Image

Step 4: Create Edge/Origin Scale Sets

We need to setup scale sets. Click Create a Resource in the portal which is on the upper left. Enter Application Gateway in the Search the Marketplace box at the top of the New pane that appears. Click Application Gateway when it appears in the search results.

Image

Select Classic in the Select a deployment model box in the "Virtual Machine Scale Set" pane that appears, then clicks Create.

Image

Ilk olarak Origin Scale Set'i olusturacagiz. Resource Groupu secin Virtual Machine scale set name Region ayarlarini asagidaki gibi yapin. Browse all public and private images 'e tiklayin.

Image

Acilan pencerede Ant Media Server diye aratip "Ant Media Server Enterprise 2.1.0" surumu secin.

Image

Disk secimini yaptiktan sonra "Next: Networking" 'i secin.

Image

Bu ekranda Virtual Network olarak onceden olusturmus oldugumuz antmedia-cluster-virtual-network 'u secin. Network interface olarak origin subnetini secin ve Use a load Balancer Yes tiklayin. Onceden olusturmus oldugumuz application gateway 'i secin ve Backend Pool olarak origin i secin ve "Next: Scaling" 'i tiklayin.

Image

Bu ekranda Custom'i secin ve Cpu threshold %60 'a getirin. Diger ayarlari kendinize gore yapabilirsiniz.

Image

Management ve Health sekmelerinde direk next diyerek devam edin ve Advanced kisminda Custom data alanina asagidaki satirlari ekleyin.

#!/bin/bash
cd /usr/local/antmedia/
./change_server_mode.sh cluster 10.0.2.4

10.0.2.4 IP adresi daha once kurmus oldugum MongoDB instanceinin private IP adresidir. Kendinize gore duzenleyiniz.

Image

Create butonuna tiklayarak Origin icin Scale Set'ini olusturun.

Image

Tekrar yeni bir adet Scale Set olusturun yukaridaki adimlari tekrarlayin. Sonra Networking kismini da asagidaki gibi duzenleyin. Network Interface olarak Edge Subnetu olacak ve Application Gateway Backend pool icin de Edge secili olacaktir.

Image

Son olarak scale setleriniz asagidaki gibi gozukecektir.

Image

Troubleshoot

Asagidaki sayfalar cevap veriyorsa edge/origin yonlendirmeleriniz dogru calisiyor demektir.

Edge icin login https://application-gateway-ip:5443 Origin icin login https://application-gateway-ip

Image

Cluster Menusune geldiginizde de asagidaki gibi join olmus nodelari gorebilirsiniz.

Image

User Guide

Reference

Troubleshooting

Draft

Proposals

Clone this wiki locally