Ugacomp

How to optimize the Performance of Ant Media Server

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

Optimizing the performance of your Ant Media Server can be critical to delivering high-quality video streaming to your audience. A poorly configured Ant Media Server with limited resources can lead to frustrating results in the end. In this blog, we would like to take you through a couple of things you can do to ensure that your Ant Media live streaming is effective while mitigating performance problems you’re likely to face:

Use a good VPS Server

Choosing a good VPS (Virtual Private Server) is critical to delivering high-quality live streaming with Ant Media Server because a VPS is a foundation on which your live streaming platform runs. The performance of your VPS will determine the quality of your live stream, including its stability, reliability, and speed. If your VPS cannot handle the demands of your live streaming platform, your audience will experience buffering, latency, and other issues that can damage the viewing experience and hurt your brand.

One of the key factors to consider when choosing a VPS for live streaming with Ant Media Server is the server’s processing power. The server should have enough processing power to handle the encoding and decoding of live video streams in real time.

You should consider the amount of RAM and bandwidth available to your server, as these resources can also impact the quality of your live stream. Choosing a VPS with a high-speed internet connection can help ensure that your live stream is delivered to viewers quickly and with minimal buffering. Ultimately, selecting a high-quality VPS is crucial for delivering a reliable and high-quality live streaming experience with Ant Media Server.

Do you need Dedicated Server hardware for Ant Media?

If you’re considering using Ant Media Server to deliver live streams, one of the key decisions you’ll need to make is whether to use a dedicated server or a VPS (Virtual Private Server). While a dedicated server provides higher levels of performance and control, it may not always be necessary for your needs.

Let’s first talk about why a dedicated server is often recommended for live streaming. With a dedicated server, you have complete control over the server environment, allowing you to optimize it for performance and reliability. Dedicated servers typically have more powerful hardware and greater bandwidth allowances, which is necessary when streaming high-quality video to a large audience.

However, using a dedicated server can be costly, and it requires a higher level of technical expertise to set up and maintain. This can be a barrier for individuals and small organizations with limited budgets and resources. This is where a VPS comes in as a more affordable alternative. A VPS still provides you with dedicated resources, but at a lower cost than a dedicated server. It also allows you to customize your server environment, giving you greater control over your hosting environment.

So, when is it appropriate to use a dedicated server, and when is a VPS sufficient for your needs? The answer depends on several factors, including the size of your audience, the quality of your video source, and your budget.

If you’re streaming to a large audience or delivering high-quality video, a dedicated server may be necessary to ensure optimal performance and reliability. Additionally, if you have the technical expertise and resources to set up and maintain a dedicated server, it may be worth the investment.

On the other hand, if you’re streaming to a smaller audience or using lower-quality video, a VPS may be sufficient for your needs. It provides you with dedicated resources at a lower cost, while still giving you control over your hosting environment.

Ant Media Server is a popular open-source media server that allows users to stream and record live video and audio. Optimizing Ant Media Server performance can improve the quality of your streams and reduce latency, buffering, and other performance issues. Here are some tips on how to optimize Ant Media Server performance:

Optimize server configuration

Ant Media Server offers a couple of configurations that can be adjusted and customized to offer better performance

Change the Java Heap Size

Ant Media Server is built on top of Java, so adjusting the Java Heap Size can significantly impact its performance. The Java Heap Size is the amount of memory allocated to the Java Virtual Machine (JVM) to run the Ant Media Server. By default, the Java Heap Size is set to 2 GB, but depending on your use case, you may need to increase or decrease this value.

To adjust the Java Heap Size, you need to modify the setenv.sh or setenv.bat file located in the Ant Media Server installation directory: /usr/local/antmedia/. In this file, you will find a variable called CATALINA_OPTS, which you can modify to adjust the Java Heap Size.

For example, to increase the Java Heap Size to 4 GB, you can set the following value:

CATALINA_OPTS="-Xmx4g"

Configure the Thread Pool

The thread pool is a collection of threads that are created and maintained by Ant Media server to handle incoming requests from clients. When a request is received, the server assigns it to an available thread in the pool, and the thread handles the request. Once the thread completes the request, it is returned to the pool to be used for another incoming request.

By default, the thread pool size is set to 200. Still, you can adjust this value by modifying the tomcat/conf/server.xml file located in the Ant Media Server installation directory. In this file, you can adjust the parameter called maxThreads to increase the thread pool size.

For example, to set the thread pool size to 500, you can add the following parameter to the section:

maxThreads="500"

However, it’s important to note that If your Ant Media Server is running smoothly with default settings, there may not be a need to adjust the thread pool size. Default settings are optimized for most use cases, and changing them may not lead to significant performance improvements.

Activate adaptive bitrate streaming

Adaptive bitrate streaming is a technique that adjusts the quality of a video stream based on the viewer’s internet speed.

Adaptive bitrate streaming has become an essential tool for live streaming services such as Ant Media. By dynamically adjusting the quality of the video stream based on the viewer’s network connection, adaptive bitrate streaming ensures a smooth and uninterrupted viewing experience for your streaming audience.

Ant Media utilizes adaptive bitrate streaming to optimize live streaming by continuously monitoring the viewer’s internet speed and adjusting the video quality accordingly. This technology detects variations in network speed and automatically switches the video quality to ensure a seamless viewing experience without buffering or delays.

One of the primary advantages of adaptive bitrate streaming is that it maximizes viewer engagement by providing high-quality video content. The video quality is optimized based on the viewer’s internet speed, ensuring that the video stream is always of the highest possible quality without interruption.

Furthermore, adaptive bitrate streaming also helps to reduce the load on the network. By optimizing the video quality based on the viewer’s internet speed, the streaming server doesn’t need to constantly send data at a high bitrate. This reduces the risk of network congestion, which can lead to buffering or delays in the video stream.

If you want to take advantage of adaptive bitrate streaming, you will need to upgrade to the enterprise edition of Ant Media Server. Then, you need to do the following to activate it:

  • Log in to your Ant Media Server dashboard. Navigate to the “Settings” tab and select the “Adaptive Streaming” option. Here, you can enable or disable adaptive streaming, set the minimum and maximum bitrates, and specify the segment duration.

  • Once you have configured the adaptive bitrate streaming settings, start your live stream on Ant Media Server. The server will automatically detect the viewer’s internet speed and adjust the video quality accordingly.

  • To test whether adaptive bitrate streaming is working correctly, try watching the live stream on different devices with varying internet speeds. You should notice that the video quality automatically adjusts to provide the best possible viewing experience.

Enable hardware acceleration

Server hardware acceleration refers to the use of specialized hardware components to offload or accelerate computationally intensive tasks from the central processing unit (CPU) of a server. This approach is used to increase the overall performance and efficiency of the server.

Hardware acceleration can be achieved through the use of dedicated hardware components such as graphics processing units (GPUs), field-programmable gate arrays (FPGAs), and application-specific integrated circuits (ASICs). These components are designed to perform specific tasks more efficiently than a general-purpose CPU, which can lead to significant performance gains.

Ant Media Server supports hardware acceleration, which offloads processing tasks from the CPU to the GPU, resulting in better performance and reduced CPU usage.

To optimize performance and enhance user experience, Ant Media can utilize GPU hardware acceleration to perform tasks such as video encoding, decoding, and transcoding more efficiently, resulting in better video quality, faster processing times, and reduced latency.

Hardware acceleration allows Ant Media to allocate more resources to other tasks and reduce the load on the CPU, leading to smoother playback, faster loading times, and better overall performance. By utilizing hardware acceleration, Ant Media ensures high-quality, reliable, and efficient media streaming and management services to users.

How to Enable GPU acceleration in Ant Media Server

To enable GPU hardware acceleration in Ant Media, follow these steps:

  • Ensure that your GPU meets the system requirements for Ant Media. Check the Ant Media documentation for specific requirements.

  • Install the necessary GPU drivers for your system. The GPU drivers should be compatible with your operating system and the version of Ant Media that you are running.

  • Configure Ant Media to use GPU acceleration. This can be done in the Ant Media management console under the “Settings” section. Look for the “Hardware Acceleration” option and select “GPU” from the dropdown menu.

  • Once GPU acceleration is enabled, you can configure specific settings for video encoding, decoding, and transcoding to take advantage of the GPU. In the Ant Media management console, go to the “Encoding Settings” section and configure the settings according to your needs.

  • Test your GPU acceleration settings by running a sample video or live stream. Monitor the performance and quality of the stream to ensure that it meets your expectations.

Integrate Content Delivery Network (CDN)

One of the great features of AMS is its ability to integrate with Content Delivery Networks (CDNs) to distribute live video streams and reduce the load on the server. With CDN integration, you can scale your live video streaming by serving your content from multiple edge locations, reducing the latency and improving the viewer’s experience.

To enable CDN integration in Ant Media, here is what you need to know:

  • The first step is to choose a CDN provider that fits your requirements. Popular CDN providers such as Amazon CloudFront, Akamai, and Wowza CDN are supported by Ant Media. Once you have chosen a CDN provider, obtain the necessary credentials for the CDN integration. Each CDN provider has its own way of obtaining credentials, so refer to the provider’s documentation for the specific steps.

  • Activate CDN integration in Ant Media by going to the dashboard web panel, selecting Settings > Server > CDN, and enter the CDN provider credentials. Once enabled, you can configure it to publish a live stream to a CDN. To do this, go to Streams > Add Stream and select the CDN publishing option. Enter the CDN endpoint and other necessary information.

  • Finally, it’s time to test the CDN integration. Start a live stream and verify that the stream is being distributed through the CDN. You can check the CDN logs or use a CDN monitoring tool to verify the CDN integration.

Optimize the Network Configuration

Ant Media Server relies heavily on the network configuration to perform well. By default, Ant Media Server is configured to use the standard TCP protocol, which may not be the most efficient protocol for streaming video content.

To optimize the network configuration, you can use a protocol like User Datagram Protocol (UDP), which is designed for real-time streaming applications. To enable UDP in Ant Media Server, you need to modify the tomcat/webapps/LiveApp/WEB-INF/red5-web.properties file located in the Ant Media Server installation directory.

In this file, you will find a section called “RtmpHandler“, and you can add the following parameter to enable UDP:

"rtmp.transport.type=udp"

Request for more bandwidth

Bandwidth is the amount of data that can be transmitted over a network in a given amount of time. When it comes to live streaming, bandwidth is critical for ensuring a smooth and uninterrupted viewing experience for viewers. The more bandwidth available, the higher the quality of the stream and the more viewers that can be supported.

One of the main challenges that Ant Media broadcasters face when dealing with service providers is limited bandwidth. In many cases, service providers may cap the amount of bandwidth available to users, particularly during peak usage hours. This can result in reduced video quality, buffering, and even dropped frames.

Even if a service provider offers a high-bandwidth plan, the actual amount of bandwidth available can vary depending on a range of factors, including network congestion and the number of other users on the same network. This can result in a stream that is inconsistent and prone to interruptions.

So, if you’re facing bandwidth problems, you will need to talk to your VPS or infrastructure provider so they can provide you with more capacity that can handle your Ant Media live streaming needs.

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.