Try Live Demo

Unlock the full potential of your streaming platform with our in-depth guide on how to scale Ant Media Server on Google Cloud Platform (GCP).  

As the demand for seamless, high-quality live streaming continues to surge, mastering the art of scalability becomes essential.

In this comprehensive post, we’ll navigate the intricacies of efficiently expanding your Ant Media Server infrastructure on GCP, ensuring optimal performance and an exceptional viewing experience for your audience.

Let’s move on to the installation.

After logging into Google Cloud Platform, create a project for yourself. We created antmedia-test for testing purposes.

Step 1: Install MongoDB Server

To create an instance in Google Cloud Platform:

Click on VM Instances > CREATE INSTANCE, and from the opened window, choose Ubuntu 22.04 as the boot disk.

Then, go to Advanced Options > Management. Add the following lines to the Automation section:

#!/bin/bash
wget https://raw.githubusercontent.com/ant-media/Scripts/master/install_mongodb.sh && chmod +x install_mongodb.sh
./install_mongodb.sh

Click on Create to complete the process. Once the instance is created, make sure to note down its private IP address.

Step 2: Install Ant Media Server Enterprise Edition

To use Ant Media Server Enterprise Edition as a cluster on Google Cloud Platform Marketplace, you should first deploy Ant Media Server Enterprise Edition through the Marketplace service. Please check out this blog post to launch the AMS through the marketplace.

scale ant media server on google cloud platform

Ant Media Server on Google Cloud Platform Marketplace

After the deployment process is complete, stop the instance.

Next, navigate to the Images > CREATE IMAGE tab and choose the instance you have set up as the Source disk.

ant media server set up google cloud

Choose Source disk for Ant Media Server on Google Cloud

Step 3: Create an Instance Template

After the image creation process is complete, proceed to the Instance Templates > CREATE INSTANCE TEMPLATE menu.

Select the instance type

ant media instance template google cloud

Create Ant Media Server instance template on Google Cloud

On the same screen, navigate to the Boot Disk section and click on Change > Custom Images. Then, select the image you created in the previous step.

ant media server set up cloud

Create Ant Media Server instance template on Google Cloud – Boot Disk

After that, go to Advanced Options > Management Tab and add the following startup script to the Automation section:

#!/bin/bash
rm -rf /usr/local/antmedia/conf/instanceId
rm -rf /usr/local/antmedia/*.db.*
rm -rf /usr/local/antmedia/*.db
cd /usr/local/antmedia
./change_server_mode.sh cluster 10.128.0.5

In the script, please replace the private IP of your MongoDB created in Step 1. Click the Create button to create the template.

Step 4: Create the Instance group

Navigate on Google Cloud to Compute Engine > Instance Groups > CREATE INSTANCE GROUP. Then, select the name and template as shown in the screenshot, and choose Multiple Zones for the Location.

instance group google cloud

Create instance group on Google Cloud

For auto-scaling, specify the minimum and maximum instance counts you want to set up, then configure the CPU Utilization to 60% and click on the Create button.

Then repeat the same process for the Edge group as well.

Step 5: Create a Load Balancer

The autoscaling groups are now created. Let’s move on to configuring the Load Balancer to distribute the load.

In the search bar, type “Load Balancer” and open the “Load balancing” service, then click on CREATE LOAD BALANCER and select Application Load Balancer.

config app load balance google cloud

Start configuration for Application Load Balancer on Google Cloud

In the Load Balancer menu, after selecting the Name and Protocol, go to the certificate section and create a new certificate by choosing “CREATE A NEW CERTIFICATE.”

https certificate google cloud

Create a new HTTPS certificate on Google Cloud

create certificate google cloud instruction

How to create a certificate form on Google Cloud

Then, fill in the required fields and create the certificate. You can also use your own SSL certificate by uploading it. After that, click on the “Backend configuration” section.

create backend service google cloud instruction

Create a backend service on GoogleCloud

backend service setup google cloud

How to configure backend service on GoogleCloud?

In the upcoming screen, we will create the Backend Pool (both Origin and Edge) and Health Check.

In the same backend configuration, to create the Health Check configuration, click on Health Check > CREATE HEALTH CHECK and add it as shown below:

health check google cloud

How to set up the Health Check on Google Cloud?

Click on Create to finalize the configuration for both the Backend and the Health check. Then, click Create again to complete the Load Balancer configuration.

Repeat these steps for the Edge side as well.

Note: If the Load Balancers cannot access the Backend servers, you should add a firewall rule as shown below.

Go to VPC Network > Firewall > Create firewall Rule and add the rule as shown below. Now the load balancer should be able to access the Ant Media Server Backend servers.

You can allow all IPs by adding the 0.0.0.0/0 CIDR block if required.

firewall policies google cloud

How to set up Firewall policies on Google Cloud?

Step 6: Configure Firewall rule for Ant Media Servers

For TCP port 5000 and UDP ports 50000–60000, go to VPC Network > Firewall > Create firewall rule and add the rule as shown in the image below.

firewall rule ant media google cloud

How to Configure Firewall rule for Ant Media Servers on Google Cloud?

Finally, in your DNS management, define the IP addresses of both the origin and edge load balancers.

That’s it! You’re all set. You can now access the Ant Media Server servers to publish, and play the streams using either the origin or edge group.

create account ant media server

Create a Managing Account for Ant Media Server

ant media server dashboard cluster

Cluster overview on Ant Media Server dashboard

Categories: Tutorial

Murat Ugur

Murat is a Software Developer and a Technical Support Engineer at the same time at Ant Media. With a remarkable 15+ years in the IT domain, including 13 years dedicated to Linux System administration, Murat brings a wealth of experience to the table. His expertise is grounded in technologies like bash scripting, python, and puppet.