Tutorial

Streaming Success: Mastering HLS Delivery with CloudFront & S3

Home Tutorial Streaming Success: Mastering HLS Delivery with CloudFront & S3
Mohit Dubey Author
Jan 22, 2026 7 min read

Scaling HLS delivery to a global audience demands more than technical prowess—it requires a strategic blend of innovation and reliability. Imagine millions of eager viewers awaiting seamless streaming experiences, powered by a robust CDN and fortified with cloud-backed storage. This is where the journey begins.

In this blog post, we unveil the seamless fusion of Ant Media Server with Amazon CloudFront and S3, igniting a revolution in HLS delivery that transcends boundaries and redefines reliability. Welcome to a world where scalability meets certainty, where every stream flows effortlessly, reaching millions with unparalleled ease and precision. Buckle up as we unravel the secrets behind Scaling HLS Delivery: CloudFront & S3 for Reliability.

Storing HLS Files on S3 Bucket in Real-time

Empowering real-time uploads of HLS files to diverse S3-compatible buckets, including AWS S3, OVH Object Storage, Digital Ocean Spaces, and more, Ant Media Server ensures zero data loss during live streams.

Before uploading HLS files to S3 buckets, ensure you have an S3 bucket ready. Create your bucket on any S3-compatible cloud platform. If unsure, refer to our document on creating S3 buckets in various clouds.

For this post, I’ll use an AWS S3 bucket. Now, with the S3 bucket prepared and credentials in hand, let’s proceed to save the details.

Step 1: Saving Bucket Credentials On the Web Panel

Easily save the bucket details on the Ant Media Server dashboard by navigating to Application > Settings > Enable S3 Recording under Stream Recording.

s3 credentials

Step 2: Configuring HLS Upload Settings

In this step, we’ll incorporate the required flags to enable real-time uploading of HLS files to S3 buckets. Navigate to the dashboard’s Application Settings section and choose Advanced from the dropdown menu.

advance settings

Find the setting ‘hlsHttpEndpoint’ and set it to:

hlsHttpEndpoint=http://localhost:5080/LiveApp/hls-upload

In this context, ‘LiveApp’ is the application name, and you can substitute it with your preferred application.

realtime hls upload

Upon commencement of HLS file uploads to the S3 bucket, you will observe similar log excerpts on the server side:

2023-08-24 16:02:55,703 [java-sdk-progress-listener-callback-thread] INFO io.antmedia.servlet.UploadHLSChunk – File uploaded to S3 with key: streams/blogpost-hls-upload-2023-08-24_16-02-52.970.m3u8 2023-08-24 16:02:55,734 [java-sdk-progress-listener-callback-thread] INFO i.a.storage.AmazonS3StorageClient – File uploaded to S3 with key: streams/blogpost-hls-upload-2023-08-24_16-02-52.970000000000.ts

Personalizing Real-Time HLS Uploads

Now that we’ve mastered real-time HLS file uploads to the S3 bucket, let’s maximize the benefits of real-time HLS uploads by fine-tuning key settings for optimal performance and reliability.

To store all .ts files for a given streamId, it is crucial to configure the following properties:

hlsflags=+append_list
hlsPlayListType=event
deleteHLSFilesOnEnded=false

To prevent overwriting HLS files when using the same streamId, enable date and time for HLS files:

addDateTimeToHlsFileName=true

With this property, when utilizing the same streamId, the existing HLS files won’t be overwritten, as they will have distinct timestamps:

hls uploads

Congratulations! You can now store HLS files in the S3 Bucket while the stream is live, without waiting for the stream to conclude. Next, explore scaling HLS for large audiences with Ant Media Server and Amazon CloudFront.

HLS Delivery to Mass Audience with Amazon CloudFront and Ant Media Server:

Amazon CloudFront is a rapid content delivery network (CDN) service designed to securely distribute data, videos, applications, and APIs to a global audience. It ensures low latency and high transfer speeds, all while providing a developer-friendly environment.

Before we dive into CloudFront configuration, please make sure that you have your Ant Media Server running and an AWS account.

Creating CloudFront Distribution

Log in to your AWS account and go to CloudFront.

Click Create Distribution.

  • Fill out the form as shown in the screenshot.

cloudfront distribution

The Origin Domain Name refers to the domain of your server where Ant Media Server is installed.

The Origin Path is the designation for the Ant Media Server application, with examples being WebRTCAppEE and LiveApp. For this tutorial, we utilized WebRTCAppEE.

The HTTP Port is configured as 5080.

The Origin Protocol Policy is configured as HTTP to eliminate the need for SSL. Opting for HTTPS would require the setup of SSL.

  • Fine-tuning Cache Behavior.

Configure the Default Cache Behavior Settings as shown in the screenshot.

cache behaviour

On this screen, every field is configured with its default values, except for the cache policy.

To create a custom policy, click on the create policy field, and the settings should match those depicted in the image below.

edit cache policy

  • Disable Web Application Firewall (WAF) settings.

waf

After that, do not change any other settings, and now click Create Distribution.

waf settings

The distribution will be generated and displayed in the CloudFront console.

distribution

  • Configuring Cache Duration

Next, we will configure the cache duration to 3 seconds.

Click on the distribution listed in the CloudFront console, navigate to the Error Pages tab, and within this tab, click on Create Custom Error Response.

error code

Choose 404: Not Found as the HTTP Error Code.

Set the Error Caching Minimum TTL to 3 seconds, and then click the Create button.

error response

  • CloudFront Domain Name.

Wait until the distribution is deployed. Then note your CloudFront Domain Name.

distribution completed

Congratulations! Now that you have successfully created the CloudFront distribution, let’s test together.

Create a Live Stream

Follow the Publish Live Stream guide to start a stream.

For this example, publish an RTMP stream using OBS.

Play the Live Stream with HLS

Use the following format for HLS playback:

http://your_cloud_front_domain_name/play.html?id=your_stream_id&playOrder=hls

For example:

http://d3m1pdd4lln4vj.cloudfront.net/play.html?id=stream01&playOrder=hls

When you open this URL in your browser, you should now observe your stream playing, distributed through the CDN by leveraging the power of CloudFront for global distribution.

playing hls with cloudfront cdn

Frequently Asked Questions

How does Amazon CloudFront help scale HLS streaming with Ant Media Server?

Amazon CloudFront caches HLS playlists and segments at global edge locations, reducing load on Ant Media Server and enabling smooth playback for large audiences worldwide.

Why is Amazon S3 used with CloudFront for HLS delivery?

Amazon S3 acts as durable storage for HLS segments and playlists, allowing CloudFront to fetch and distribute content efficiently without relying directly on the streaming server.

Can this setup handle high-traffic live streaming events?

Yes. Ant Media Server combined with S3 and CloudFront is designed for high-scale live streaming, supporting thousands of concurrent viewers with consistent performance.

Does using CloudFront increase HLS streaming latency?

No. CloudFront typically improves stream stability and startup time by serving content from nearby edge locations, without adding noticeable latency.

Conclusion

Your HLS content is now primed for global accessibility, with CloudFront’s rapid content delivery and S3’s rock-solid storage backing every byte. With Ant Media Server’s seamless integration, scalability, and reliability going hand in hand, ensures your content shines bright, reaching millions with ease.

If you have questions or need any type of support, contact us via a form or schedule a meeting to have a coffee and chat, or write directly to [email protected] so that we can democratize live streaming together

#Amazon Cloudfront HLS
Share:

Ready to Transform Your Streaming Experience?

Start your free trial today and discover why thousands choose Ant Media for their streaming needs.

No credit card required • Setup in minutes • Cancel anytime