Skip to content

Scaling with Alibaba

Selim Emre Toy edited this page Aug 16, 2021 · 19 revisions

In this document, we’re going to explain how to setup a Scalable Ant Media Server Cluster in Alibaba.

Here below is the diagram about how Ant Media Server is architecturized within Alibaba.

AWS Cluster Architecture

Lets start with brief definitions

  • MongoDB Database Server: Ant Media Server uses MongoDB in clustering. Streams information are saved to MongoDB so that edge instances can learn any stream’s origin node.
  • Load Balancer: LB is the entrance point for the publishers and players. Load Balancer accepts the requests from publishers or players and forwards the requests to the available node in the cluster.
  • Origin Auto-Scalable Group: Nodes(Instances) in the origin group accepts the publish requests and ingest the incoming WebRTC stream. When an origin instance accepts a WebRTC stream, it saves the related information to the MongoDB Database Server. There may be one node or multiple node in origin group. It may even be manually or auto scalable. In our deployment, it’s auto-scalable in Alibaba.
  • Edge Auto-Scalable Group: Node(Instances) in the edge group accepts the play requests. Then it learns from MongoDB which origin node has the related stream. After that it gets the stream from related origin node and sends the stream to the player.

Then continue with installing MongoDB Server

Step 1: Install MongoDB Server

The procedure below shows how to start an instance in Alibaba Elastic Compute Service as well. In other words, if you have no experience with Alibaba, you can even install MongoDB Server as follows. If you know how to start an instance in Alibaba, just skip to “Install MongoDB to Your Instance”

  • Signup to Alibaba Cloud if you don’t have an account yet. Login to Alibaba Cloud Console. Then click Elastic Compute Service as shown in the image below.

  • Click “Create Instance”.

  • Select Billing model and Instance type according to your use case.

  • Choose Instance Type like Enhanced General Purpose Type g6e series.
    • You may optionally choose a bigger instance according to your streaming load.

Search for “Ubuntu” and Select “Ubuntu 18.04” and Click

  • Click “Edit Security Groups” in the image.

  • Add “22” and “27017” TCP ports as follows in the image. Warning is critical for security. We’ll restrict source into a VPC later. Just click “Review and Launch” .

Important Note: You need to open TCP port range(TCP:5000-65000) for the internal network. It should not be open to public.

  • In the coming window, Click “Launch” button again. Then it will ask to specify key file. Choose “Create new key pair” and click “Download Key Pair” button. After key file is downloaded. Click “Launch Instances”

  • Right now, your instances should be launching as shown in the image

  • Go to EC2 Instances and Click “Connect” button.

  • It shows a dialog as follow and connect to instance via ssh

  • Right now, you should connect to your instance. To Connect your instance, open a terminal and run a command something like. Please change {YOUR_KEY_FILE} and {INSTANCE_PUBLIC_IP} with your own credentials. For our case, they are “ant.pem” and “ec2-35-159-50-16.eu-central-1.compute.amazonaws.com”

ssh -i {YOUR_KEY_FILE} ubuntu@{INSTANCE_PUBLIC_IP}

Install MongoDB to Your Instance

  • After you get connected, run the following commands in order to install MongoDB to your instance
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
  • Open /etc/mongod.conf file with an editor like nano and change bind_ip value to 0.0.0.0 to let MongoDB accept connections in all interfaces and save it.

sudo nano /etc/mongod.conf

Press “Ctrl + X” to save the file.

Restart mongod and enable service.

sudo systemctl restart mongod
sudo systemctl enable mongod.service

MongoDB installation is complete, just save your MongoDB instance’s local address somewhere. We will use it in later.

User Guide

Reference

Troubleshooting

Draft

Proposals

Clone this wiki locally