Ugacomp

What you need to know before deploying Ant Media in AWS Cluster

Where necessary, you may need to have access to a VPS server so you can follow how to implement the steps in this article.  You can get a cheaper VPS Server from Contabo with 4vCPU cores, 8GM RAM, and 32TB Bandwidth for less than $5.50 per month. Get this deal here now

Table of Contents

Cloud VPS S

$5.50 Monthly
  • 4 vCPU Cores | 8GB RAM

CLOUD VPS M

$15.50 Monthly
  • 6 vCPU Cores | 16GB RAM

CLOUD VPS L

$17.50 Monthly
  • 8 vCPU Cores | 24GB RAM

Configuring and deploying Ant Media in a cluster on AWS is the best way to go for a large-scale streaming setup to serve tens of thousands of concurrent viewers. Putting Ant Media in a cluster means that your infrastructure will be able to automatically scale during the time of traffic spike on your streaming sessions. Such configurations can make it possible to send out live streaming broadcasts to your audience seamlessly, limiting downtime issues that could result from insufficient resources if you were to run a single server architecture.

It’s important to note that setting up a sophisticated streaming infrastructure can become problematic if you don’t have an advanced understanding of the core AWS services. An infrastructure of this scale can involve configuring a couple of AWS services that make up the cluster. In this blog, we would like to help you understand everything you need to know about what it takes to set up an Ant Media cluster on AWS.

Amazon EC2 instances for Ant Media Server

Your cluster deployment starts with the ec2 instances you want to deploy. In fact, the heart of your infrastructure is going to start from here.

EC2) is an AWS computing service that enables users to rent virtual machines so they can run applications and services on them.

EC2 provides scalable computing capacity in the cloud, allowing users to quickly launch virtual machines (VMs) with a variety of operating systems and configurations.

If you want to deploy a large-scale streaming architecture on AWS, ec2 instances are your first considerations to think about. You need to know which type of ec2 instances are good for you and how much they each cost if you’re to deploy a bunch of them.

Trying to figure out the best instance family for your Ant Media deployment could be tedious, especially if you’re a newbie in this field. The truth is, to benefit from AWS’s computing power while avoiding excessive costs, you must be familiar with how this platform works.

RECOMMENDED READING: How does Alibaba Cloud Free trial work?

How many AWS ec2 instances do you need to deploy?

The number of EC2 instances needed for Ant Media clustering depends on the specific requirements and the scale of the deployment. There are a couple of factors to put into consideration here while determining the number of ec2 servers you need to deploy in your cluster:

  • The expected number of concurrent users:

The size of the audience you expect to serve concurrently will determine how many servers you have to configure in a cluster. Ant Media recommends that for every 200 concurrent viewers, you need a server instance with at least 4 CPU cores & 8GB RAM as the starting point.

  • Video quality

When you think about streaming, it’s not just about the number of concurrent viewers. It’s also about the quality of the videos you intend to stream. High-resolution videos require more computing power and bandwidth to successfully stream them. And the costs can rise quickly if you don’t know what you’re doing. For example, streaming a 480p video is not the same as streaming a 1080p video. These two video qualities vary and are not the same when it comes to resource consumption on your server.

Obviously, the two streams would not require the same amount of server CPU and RAM. The 1080p stream requires more processing power and bandwidth compared to the 480p stream. It would be expensive to encode and stream 1080p video as it requires more processing power than encoding or streaming a 480p video. As a result, the server hosting the 1080p stream would need more CPU and RAM resources to deliver a smooth and high-quality streaming experience to the viewers.

  • The type of Amazon ec2 instances

The type of instance family you choose on AWS will also determine the number of server instances you deploy. You should know that there are probably 100s or even 1000s of instance types on AWS. But not all ec2 instance types are the same. Some have low-computing resources and others are compute-optimized to handle resource-intensive workloads. For example, the t2.nano instance type is not the same as the p3 instances in terms of computing resources. But also, it’s not just about selecting the most powerful servers on AWS. It’s about balancing the capacity you need and the costs you’re willing to incur.

The good thing about AWS scalable deployments is that you can only pay for what you use based on the pay-as-you-go model. This means that if you expect to have gradual traffic growth, the number of servers will automatically scale and you will only pay when they increase in the cluster.

For your reference, here is the table showing the amount of computing power you need to stream to a certain number of concurrent viewers;

No. of CPU CoresAmount of RAMTotal Number of Current Viewers
4vCPU8GB200 Viewers
8vCPU16GB400 Viewers
16vCPU32GB800 Viewers
32vCPU64GB2000 viewers
64vCPU128GB4000 viewers
128vCPU256GB8000 Viewers
256vCPU512GB20,000 Viewers

How much will you pay for AWS ec2 instance to deploy Ant Media Server?

The costs you will incur will depend on the ec2 instance family or category you choose for your Ant Media server cluster deployment. Each ec2 instance family is charged differently depending on the amount of computing power (CPU & RAM) attached to them). See the table below;

Instance
Type
vCPU coresRAMStorageNetwork BandwidthPrice per Hour
(USD)
Price per Month
(USD)
c4 xLarge 4 vCPU
( 2.9GHz Intel Xeon)
7.5 GB EBS-Only Up to 10 GBps$0.2≈ $144
c5.xlarge4vCPU
(3.5GHz Intel Xeon – Cascade Lake 8223CL)
8GBEBS-OnlyUp to 10GBps$0.17≈ $122.4
c5n.xlarge4vCPU
(3.0 GHz Intel Xeon Platinum)
10.5GBEBS-Only Up to 25GBps$0.22≈ $158.4
c5a.xlarge4vCPU
(3.3GHz AMD EPYC 7R32 – 2nd Gen)
8GBEBS-OnlyUp to 10GBps$0.15≈ $108
c6a.xlarge4vCPU
(3.6GHz AMD EPYC 7R13 – 2nd Gen)
8GBEBS-OnlyUp to 12.5GBps $0.15≈ $108

The table above gives you a simple analysis of the Compute Optimized instance types and their respective prices. Ultimately, the exact prices of EC2 instances required for Ant Media clustering will depend on your specific use case and can be determined through testing and performance analysis.

Amazon Virtual Private Cloud

This is another imponent component required when deploying Ant Media Server on AWS cluster. Amazon VPC is a service that lets you launch AWS resources into a virtual private cloud that you’ve defined or configured. It enables you to define a virtual network topology that closely resembles a traditional network that you’d operate in your own data center.

What makes up an Amazon VPC for Ant Media cluster?

An AWS Virtual Private Cloud (VPC) infrastructure typically includes the following:

  • Subnets:

A subnet is a group of related IP addresses. For example, if a network has a subnet of 172.16.10.0/24, it means that it includes all IP addresses ranging from 172.16.10.1 to 172.16.10.254.

A subnet can either be divided into smaller subnets or used as a standalone network. It’s also important to note that if you’re going to set up a VPC network for your Ant Media cluster on AWS, you will be using private IP addresses. These addresses are defined by three blocks of IP ranges that are reserved for private networks, and they include; 10.0.0.0/8, 172.16.0.0/12, and 192.168.0.0/16.

How many IP addresses do you need for an Ant Media cluster?

To determine the total number of IP addresses or subnets you would need for a cluster deployment, you need to first determine the number of servers you want to deploy in a cluster. The following table gives you a simple picture of the number of IPs you may need based on the number of servers you intend to deploy in a cluster:

Number of serversExtra IP addressesTotal IP addressesSubnet PrefixSubnet Mask
1021210.0.0.0/27255.255.255.224
2042410.0.0.32/27255.255.255.224
3063610.0.0.64/27255.255.255.224
4084810.0.0.96/27255.255.255.224
50106010.0.0.128/27255.255.255.224
60127210.0.0.160/27255.255.255.224
70148410.0.0.192/27255.255.255.224
80169610.0.0.224/27255.255.255.224
901810810.0.1.0/27255.255.255.224
1002012010.0.1.32/27255.255.255.224

  • Network Security Groups

Network security groups are used to control inbound and outbound traffic to and from the instances in the VPC network of the Ant Media Cluster. We use the security groups to open ports necessary for Ant Media server to run.

  • NAT Gateway

An AWS NAT Gateway is a managed network service that enables instances in a private subnet to connect to the internet or other AWS services, without exposing their private IP addresses to the public internet. When deploying Ant Media cluster on AWS, the NAT Gateway can be deployed in a Public subnet as part of the overall infrastructure. It works by translating the private IP addresses of instances in the private subnet of the autoscaling group and routing traffic to the internet.

  • Routing Tables

Routing tables are used to route traffic between subnets within your VPC and between your VPC and the Internet. In the autoscaling architecture, the private subnet containing the instances in the autoscaling group and the Elastic Load Balancer would be associated with a custom routing table. This custom routing table would define the routes for traffic between the private subnet and the NAT Gateway in the public subnet. Specifically, the routing table would contain a route that directs all traffic destined for the internet to the NAT Gateway. This allows instances in the private subnet to access the internet and other AWS services via the NAT Gateway.

Do you need to create an Amazon VPC when deploying Ant Media Cluster?

It will depend on the number of servers you want to deploy in a cluster. For a simple cluster with a total number of servers less than 10, you don’t have to scratch your head trying to get into how to set up the VPC.

It’s important to note that you can only create your own Virtual Private Cloud or VPC network on AWS if you have a better understanding of cloud networking. If you’re not familiar with the technical aspect of networking in the cloud, then you just have to use the default VPC network created for you.

When you’re just starting with AWS, a default VPC is automatically created in the region you specify during the account creation. The default VPC is designed to provide a common VPC that can be used for the majority of use cases. The default VPC provides a public subnet for Internet access, as well as private subnets for instances that require private network access. You can use the default VPC or you can create custom VPCs to meet your specific needs.

How much do you pay for Amazon VPC?

You’re not charged for creating and using an Amazon VPC itself. But you can incur usage charges for certain resources such as the number of IP addresses, the amount of data transfer, and the usage of other VPC services. See the table below;

VPC ResourceAmount per hour (USDEstimated Amount per month (USD)
1 active IP Address$0.00027≈ $0.1944
1 Network Gateway$0.045 ≈ $32.4
Traffic Mirroring$0.015≈ $10.8
Intra-Region Data Transfer (per TB)$0.028≈ $20.48
Outbound Data Transfer ( per GB)—–≈ $0.09 (per GB)

MongoDB Database Server

Ant Media uses MangoDB in the cluster to store stream information required by both the origin and edge instances to send or respond to particular requests related to the streaming sessions.

The MongoDB database runs as a separate standalone instance and is assigned its own computing resources from the rest of the cluster. Such a standalone database node is required in an Ant Media AWS auto-scaling cluster to separate the database and application components.

Which type of instance can I use for MongoDB Database?

For the MongoDB database instance in an Ant Media cluster on AWS, you can use general-purpose instance types like the Amazon EC2 R5a/R5, M5a/M5, or X1e/X1 series instances.

So, what are these instances?

  • R5a/R5: These Amazonec2 instances are powered by Intel Xeon Scalable processors (previously known as Skylake). These processors offer a high core count, large memory footprint, and advanced performance features such as enhanced networking, improved memory bandwidth, and support for the AVX-512 instruction set. The R5a instances are also optimized for low latency and high throughput, making them well-suited for a variety of applications, including databases. They are basically general-purpose instances with high CPU-to-memory ratios and a balance of compute memory, and network resources.

  • M5a/M5: These are general-purpose instances and they are also powered by Intel Xeon Scalable processors, offering a balance of compute memory, and network resources. They are cost-effective and highly suitable for deploying resource-intensive databases.

  • X1e/X1: These instances also use Intel Xeon Scalable processors (previously known as Intel Xeon E5-26xx v4/v3 family). They are memory-optimized instances that are designed for memory-intensive applications, including large-scale database deployments. They offer high memory capacity and low latency.

It’s important to note that your Ant Media MongoDB instance should be assigned more computing power and memory resources to prevent it from crashing as a result of massive requests that could overwhelm it.

As a rough estimate, a well-configured MongoDB database instance with better hardware resources (CPU & Memory) can handle hundreds or even thousands of requests per second.

How much can a MongoDB instance cost when deployed for Ant Media Cluster on AWS?

The type of Amazon ec2 instance you choose to use for the MongoDB server in an Ant Media cluster will determine the amount you will be charged per hour or per month. See the table below for the rough estimates:

Instance
Type
vCPU coresRAMStorageNetwork BandwidthPrice per Hour
(USD)
Price per Month
(USD)
r5.4xlarge16 vCPU
( 3.1GHz Intel Xeon Platinum 8000 series)
128GiB EBS-Only Up to 10 GBps$1.0080≈ $726
r5a.4xlarge16vCPU
(2.5GHz AMD EPYC 7000 series)
128GiBEBS-OnlyUp to 10GBps$0.9040≈ $651
m5.8xlarge32vCPU
(3.1 GHz Intel Xeon Skylake 8175M or Cascade Lake 8259CL)
128GiBEBS-Only 10GBps$1.5360≈ $1,1059.2
c5a.xlarge4vCPU
(3.3GHz AMD EPYC 7R32 – 2nd Gen)
8GBEBS-OnlyUp to 10GBps$0.15≈ $108
c6a.xlarge4vCPU
(3.6GHz AMD EPYC 7R13 – 2nd Gen)
8GBEBS-OnlyUp to 12.5GBps $0.15≈ $108

Application Load balancer

In relation to Ant Media cluster deployment on AWS, the Load Balancer (LB) can work as the entrance gateway point for the publisher and players. It takes in the requests from publishers or players, and redirects traffic to an available edge node, allowing the viewers to watch the stream.

There are 3 critical components required to trigger auto-scaling and load balancing in an Ant Media cluster deployment: Origin group, MongoDB and Edge Group

Ant Media cluster Origin & Edge Groups

Ant Medis streaming cluster relies on both the origin group and the edge group. The primary purpose of the origin group is to publish requests and also ingest the incoming WebRTC streams. For example, when an origin node accepts a WebRTC stream, the information about this stream is saved on the MongoDB Database Server. The number of origin nodes can be configured to be auto-scalable in the infrastructure.

On the other hand, the edge nodes accept play requests by fetching streaming information from the MongoDB server and then locate the stream on the origin node. This way, the edge node can now send the stream to the end viewer.

For your reference, see the illustration below

Amazon S3 & CloudFront

In an Ant Media Cluster, Amazon S3 and CloudFront are used together to provide scalable and high-performance media streaming services. The way it works is that live streams are ingested into the Ant Media Cluster and recorded video files are stored in Amazon S3 as object files.

The recorded video files are then served to users via Amazon CloudFront, which is a content delivery network (CDN) provided by AWS. CloudFront caches the video files in edge locations located around the world to reduce latency and improve performance.

When a user requests a video, CloudFront automatically selects the edge location closest to the user and serves the video from that location. This helps to minimize the amount of time it takes for the video to start playing and improves the overall user experience.

CloudFront also provides additional features that are useful for media streaming, such as the ability to deliver video files in multiple bitrates and resolutions to support adaptive bitrate streaming (ABR).

So, Amazon S3 and CloudFront provide a scalable, high-performance, and cost-effective solution for media streaming in an Ant Media Cluster. They provide the necessary storage and delivery infrastructure to support large-scale live and on-demand video streaming applications.

How much do you pay for Amazon S3?

AWS offers a Free Tier plan for their Simple Storage Service (S3), which allows users to use their cloud storage service without any cost for up to 12 months after signup.

The following features are available under the S3 free tier plan;

  • Users can store up to 5GB of data in S3 for free. This storage limit includes both the standard S3 storage and the S3 Glacier storage.

  • Users can make up to 20,000 GET requests and 2,000 PUT, COPY, POST or LIST requests per month for free.

  • Users can transfer up to 1GB of data per month for free. It involves both inbound and outbound data transfers. Inbound data transfer refers to the data that is sent to S3 from the Internet, while outbound data transfer refers to the data that is downloaded from S3 to the Internet.

The free tier plan is available only to new AWS customers, and the offer is valid for 12 months from the date of account creation. Once the 12-month period is over, normal billing will apply. Additionally, if the usage exceeds the free tier limits, AWS will charge the user for the excess usage. Therefore, it is important to closely monitor usage and costs to avoid unexpected bills.

How much do you pay for Amazon CloudFront?

AWS CloudFront offers a free tier plan to help users get started with the service and experience its benefits before committing to a paid plan. The CloudFront free tier plan provides free usage of the service for up to 12 months from the date of your AWS account creation, and includes the following features;

  • It includes up to 50 GB of data transfer out per month for the first 12 months. This means that you can serve up to 50 GB of data to your users each month at no cost.

  • It includes up to 2 million HTTP and HTTPS requests per month for the first 12 months. This means that you can make up to 2 million requests to CloudFront each month at no cost.

  • It allows the ability to create up to 1 CloudFront distribution per month for the first 12 months. A CloudFront distribution is a configuration of the service that determines how content is delivered to your users.

Once you exceed the free tier limits, you will be charged for any additional usage. The exact pricing will depend on the specific usage and the pricing model selected, such as on-demand or reserved capacity. Therefore, it is important to monitor your usage and consider upgrading to a paid plan if necessary.

Amazon Route 53

Route 53 is an AWS service used to translate domain names into IP addresses that computers use to communicate with each other over the internet.

When you type a website URL into your browser, your computer sends a request to a DNS server asking for the IP address associated with that domain name. Route 53 is one such DNS server that can receive this request, and then it looks up the IP address associated with the domain name and sends it back to your computer.

Now, you will need to use Route 53 in order to create DNS records for a custom domain name required for your Ant Media cluster. It allows you to manage your DNS records, which define how traffic should be routed for your domain.

Setting up a domain is required if you’re going to add an SSL certificate to your Ant Media cluster. And so, Route 53 is the service you will need to do all the necessary DNS configurations.

How much do you pay for Amazon Route 53?

Route 53 pricing works based on a few key factors, including the number of hosted zones, the number of domain name system (DNS) queries, and the type of routing policies used. Here’s a brief explanation of each of these factors:

  • Hosted Zones: A hosted zone is essentially a container for your DNS records. When you create a domain name in Route 53, you must create a hosted zone for it. The first 25 hosted zones are free of charge. Beyond that, you will be charged a monthly fee based on the number of hosted zones you have. As of 2021, the cost for additional hosted zones is $0.50 per hosted zone per month.

  • DNS Queries: Route 53 charges for the number of DNS queries that are made against your hosted zones. This includes both standard queries (i.e. simple DNS lookups) and also queries for DNS-based load balancing and health checks. The cost of DNS queries varies based on the number of queries made per month. The estimated cost is $0.40 per million queries for the first billion queries, and then it drops to $0.20 per million queries for subsequent usage.

  • Routing Policies: Route 53 supports a variety of routing policies, including simple routing, weighted routing, latency-based routing, and others. Depending on the policy used, there may be additional charges beyond the standard DNS query fees. For example, latency-based routing charges an additional $0.60 per million queries.

Route 53 also charges for other services, such as domain registration and DNS-based traffic management (such as traffic flow and geo-routing). The pricing for these services can vary, so it’s worth checking the Route 53 pricing page or try consulting with AWS representatives for specific details.

AWS Certificate Manager

The AWS Certificate Manager (ACM) service lets you easily provision, manage, and deploy SSL certificates for use with AWS services and your own applications. When deploying an Ant Media cluster, using ACM to create and manage SSL/TLS certificates is crucial especially if you plan to embed your streams on other sites.

You can use this service to either create free SSL certificates or import third-party certificates at no additional charge

How much do you pay for AWS Certificate Manager?

The AWS Certificate Manager (ACM) Free Tier allows AWS customers to issue and deploy SSL/TLS certificates at no additional charge for use with certain AWS services. Here’s how the ACM Free Tier works:

  • Eligible services: The ACM Free Tier can be used with the following AWS services: Elastic Load Balancing, CloudFront, API Gateway, and AWS Elastic Beanstalk. If you use these services and need SSL/TLS certificates, you can use ACM to obtain and deploy them for free.

  • Certificate types: The ACM Free Tier supports the issuance and deployment of public SSL/TLS certificates only. Private certificates and certificates issued by external Certificate Authorities (CA) are not eligible for the ACM Free Tier.

  • Certificate limits: The ACM Free Tier allows you to issue and deploy up to 10 SSL/TLS certificates per year. If you need more certificates or need to use private certificates, you will need to upgrade to the paid version of ACM.

  • Certificate validity: The SSL/TLS certificates issued through the ACM Free Tier are valid for 13 months. After this time, you will need to renew or replace them to continue using them.

More Ant Media Server articles to explore

Hire us to handle what you want

Hire us through our Fiverr Profile and leave all the complicated & technical stuff to us. Here are some of the things we can do for you:

  • Website migration, troubleshooting, and maintenance.
  • Server & application deployment, scaling, troubleshooting, and maintenance
  • Deployment of Kubernetes, Docker, Cloudron, Ant Media, Apache, Nginx,  OpenVPN, cPanel, WHMCS, WordPress, and more
  • Everything you need on AWS, IBM Cloud, GCP, Azure, Oracle Cloud, Alibaba Cloud, Linode, Contabo, DigitalOcean, Ionos, Vultr, GoDaddy, HostGator, Namecheap, DreamHost, and more.
 

We will design, configure, deploy, or troubleshoot anything you want. Starting from $10, we will get your job done in the shortest time possible. Your payment is safe with Fiverr as we will only be paid once your project is completed.