

# Set up SSAI with a CDN for personalized video advertising
<a name="ssai-cdn-workflow"></a>

This section provides comprehensive guidance for integrating AWS Elemental MediaTailor server-side ad insertion (SSAI) with a content delivery network (CDN). Follow these steps to set up, configure, and optimize your SSAI CDN integration.

Server-side ad insertion (SSAI) is a technology that seamlessly inserts personalized advertisements into video streams at the server level rather than the client level. When combined with a CDN, you create a robust, scalable solution for delivering personalized advertising to global audiences with minimal latency.

In this topic, we use the term *manifests* to refer collectively to multivariant playlists, media playlists, and MPDs.

## What you'll need
<a name="ssai-cdn-what-you-need"></a>

Before setting up MediaTailor ad insertion with a CDN, gather these required resources:

**AWS account and permissions**  
An AWS account with appropriate permissions to create and manage MediaTailor resources  
IAM permissions for MediaTailor, CloudFront (if using), and related services  
For detailed permission requirements, see [Security in AWS Elemental MediaTailor](security.md).

**Required services**  
AWS Elemental MediaTailor configured and running  
A content delivery network (CDN) account (Amazon CloudFront or third-party CDN)  
Origin server for your content (HLS or DASH)  
Ad decision server (ADS) that supports VAST or VMAP

**Content requirements**  
Content properly encoded and packaged in HLS or DASH format  
Ad break markers in your content (for VOD) or SCTE-35 markers (for live)

## Before you begin
<a name="ssai-cdn-before-you-begin"></a>

Complete these setup tasks before implementing MediaTailor ad insertion with a CDN:

1. Configure network connectivity between your CDN, MediaTailor, and origin servers

1. Set up HTTPS for secure content delivery

1. Configure DNS settings for your CDN domain

1. For basic MediaTailor setup, complete the steps in [Setting up](setting-up.md) and [Getting started with MediaTailor ad insertion](getting-started-ad-insertion.md).

### Knowledge prerequisites
<a name="ssai-cdn-knowledge-prerequisites"></a>

To successfully implement this solution, you should have:
+ Understanding of streaming protocols (HLS/DASH)
+ Basic knowledge of CDN configuration principles
+ Familiarity with ad insertion concepts

## Benefits of CDN integration
<a name="ssai-cdn-benefits"></a>

Integrating SSAI with a CDN delivers these key benefits:

**Improved viewer experience**  
Properly configured CDNs reduce buffering, startup times, and playback errors during ad transitions. This results in higher viewer engagement and satisfaction.

**Cost reduction**  
Efficient caching strategies minimize origin requests. This reduces data transfer costs and origin server load, particularly important for high-volume ad-supported content.

**Scalability**  
Optimized CDN configurations handle traffic spikes during popular events without degrading performance, ensuring your personalized ads are delivered even during peak viewing times.

**Global reach**  
Properly configured CDNs deliver content with low latency to viewers worldwide, regardless of their location, expanding your potential audience.

**Seamless ad transitions**  
Optimized CDN configuration ensures smooth transitions between content and ads, creating a broadcast-quality viewing experience.

The following topics provide comprehensive guidance on configuring MediaTailor with a CDN for optimal performance.

**Topics**
+ [What you'll need](#ssai-cdn-what-you-need)
+ [Before you begin](#ssai-cdn-before-you-begin)
+ [Benefits of CDN integration](#ssai-cdn-benefits)
+ [Understand CDN architecture](ssai-cdn-architecture-overview.md)
+ [Set up basic ad insertion](configuring-ssai-cdn.md)
+ [SSAI with channel assembly](ssai-ca-integration.md)
+ [Optimize CDN performance](ssai-cdn-performance.md)
+ [Monitor CDN operations](ssai-cdn-monitor.md)
+ [Troubleshoot ad insertion with CDNs](troubleshooting-ssai-cdn.md)

# Understand ad insertion architecture for CDN and MediaTailor integrations
<a name="ssai-cdn-architecture-overview"></a>

This section explains the concepts and architecture of server-side ad insertion (SSAI) with content delivery networks (CDNs) for AWS Elemental MediaTailor. You'll learn how dynamic ad insertion and manifest manipulation work together to enable effective video monetization.

Server-side ad insertion (SSAI) with MediaTailor allows you to:
+ Insert personalized advertising into your video streams at defined ad break points
+ Target ads precisely based on viewer data
+ Eliminate the need for client-side ad insertion technology

When combined with a CDN, you can deliver these personalized streams to viewers with improved performance and scalability, enhancing your video monetization strategy.

The recommended architecture for ad insertion with a CDN positions the CDN between viewers and ad insertion, with ad insertion accessing content directly from your origin. This architecture provides the following benefits for both content delivery and video monetization:
+ Effective caching of content and ad segments
+ Reduced request load on MediaTailor
+ Improved delivery speed to viewers
+ Simplified URL management
+ Consistent delivery of personalized advertising across devices

In this recommended architecture:

1. Viewers request manifests from the CDN

1. CDN forwards requests to ad insertion

1. Ad insertion requests content manifests from the origin

1. Ad insertion requests ads from the ad decision server (ADS)

1. Ad insertion personalizes manifests by replacing the ad markers (from the origin manifest) with URLs that point to targeted ad segments for the specific viewer (from the ADS)

1. Ad insertion returns the personalized manifests containing ad segment URLs to the CDN, which forwards them to viewers

1. Viewers request segments through the CDN

1. CDN routes segment requests based on the segment type: 
   + Content segment requests go to the content origin
   + Ad segment requests go to MediaTailor 

This architecture ensures optimal performance while maintaining the security and flexibility benefits of using a CDN.

![\[Diagram showing CDN positioned between client players and AWS Elemental MediaTailor Ad Insertion\]](http://docs.aws.amazon.com/mediatailor/latest/ug/images/cdn-recommended-positioning.png)


**Note**  
This flow varies slightly between VOD and live content. For VOD, manifests can be cached longer, while live content requires more frequent manifest updates to maintain stream continuity.

The key difference between VOD and live content caching:

VOD content  
Set longer TTL values (minutes to hours) for manifests because they don't change frequently

Live content  
Set shorter TTL values (seconds) for manifests to ensure viewers receive the most current stream segments

We don't recommend that you position a CDN between your content origin and AWS Elemental MediaTailor. Doing so can introduce several technical challenges:

Cache-key collisions  
Configure your CDN to properly handle query parameters. This prevents MediaTailor from receiving incorrect manifests when requesting the same manifest with different query parameters.

Gzip compression issues  
If you experience manifest parsing errors, ensure your CDN delivers properly formatted manifests to MediaTailor. Some CDNs may deliver corrupt gzip payloads that can cause parsing failures. If this occurs, you may need to disable compression between your CDN and MediaTailor while maintaining compression for cost savings elsewhere in your workflow.

Manifest freshness  
For live streams, configure your CDN to deliver current manifests to MediaTailor. This prevents synchronization issues between content and ads.

Performance optimization  
Minimize network hops and potential cache misses to reduce playback start-up times.

Cache management  
Implement simplified cache invalidation strategies, especially for live content where manifests update frequently.

In this sub-optimal architecture:

1. Viewers request multivariant playlists, media playlists, or MPDs directly from AWS Elemental MediaTailor.

1. MediaTailor requests content manifests (multivariant playlists, media playlists, or MPDs) through the CDN.

1. The CDN forwards requests to the origin server.

1. The origin server returns multivariant playlists, media playlists, or MPDs to the CDN.

1. The CDN forwards multivariant playlists, media playlists, or MPDs to MediaTailor.

1. MediaTailor requests ads from the ad decision server (ADS).

1. MediaTailor personalizes manifests by inserting ads into multivariant playlists, media playlists, or MPDs and delivers them directly to viewers.

1. This architecture introduces additional latency, potential caching issues, and complicates troubleshooting.

![\[Diagram showing CDN positioned between content origin and MediaTailor\]](http://docs.aws.amazon.com/mediatailor/latest/ug/images/cdn-not-recommended-positioning.png)


## Request and response flow
<a name="understand-request-flow"></a>

When implementing dynamic ad insertion with a CDN, configure your system to support this request and response flow:

1. Configure your player to request multivariant playlists (HLS) or MPDs (DASH) from your CDN with MediaTailor as the manifest origin.

1. Set up your CDN to forward all multivariant playlist, media playlist, and MPD requests to MediaTailor, including all query parameters and headers.

1. Ensure MediaTailor can communicate with your ad decision server (ADS), passing along query parameters and headers.

1. Configure your ADS to use query parameters to determine which ads to insert.

1. Set up the CDN prefix on the MediaTailor playback configuration so MediaTailor can substitute CDN domain names for content and ad segment URL prefixes.

1. Configure your CDN to forward personalized multivariant playlists, media playlists, and MPDs from MediaTailor to the requesting player.

1. Set up your CDN to translate segment URLs, forwarding content segment requests to the origin server and ad requests to the Amazon S3 bucket where MediaTailor stores transcoded ads.

### CDN terminology for ad insertion
<a name="ssai-cdn-terminology"></a>

Understanding these key terms will help you implement and troubleshoot your ad insertion CDN integration:

Origin CDN and edge CDN  
**Origin CDN**: A CDN positioned between MediaTailor and your content origin. It caches content segments to reduce load on your origin servers. In a multi-CDN architecture, this is the first CDN layer that interfaces directly with the origin.  
**Edge CDN**: A CDN positioned between viewers and MediaTailor. It delivers personalized manifests and content to viewers. In a multi-CDN architecture, this is the outermost CDN layer that interfaces directly with viewers.

CDN configuration terms  
**Cache behavior**: Rules that determine how a CDN handles different types of requests. These rules include:  
+ Caching duration settings
+ Origin routing configurations
+ Request handling parameters
**TTL (Time To Live)**: The duration for which content remains valid in a CDN cache before it needs to be refreshed from the origin.  
**Cache key**: The unique identifier used by a CDN to store and retrieve cached content. It typically includes:  
+ URL path
+ Query parameters
+ Selected headers
**Origin shield**: An intermediate caching layer between CDN edge locations and your origin server. It reduces the number of requests to your origin.  
**Request collapsing**: A CDN feature that combines multiple simultaneous requests for the same content into a single origin request.

MediaTailor-specific CDN terms  
**CDN content segment prefix**: The CDN domain name that AWS Elemental MediaTailor uses when generating URLs for content segments in manifests.  
**CDN ad segment prefix**: The CDN domain name that MediaTailor uses when generating URLs for ad segments in manifests.

For more information about CDN configuration with MediaTailor, see [Set up CDN integration](cdn-configuration.md).

**Note**  
These terms are consistent with those used in channel assembly documentation. For channel assembly terminology, see [CDN terminology for channel assembly](channel-assembly-cdn-architecture.md#cdn-terminology).

# Set up basic MediaTailor SSAI with a CDN for optimal ad delivery
<a name="configuring-ssai-cdn"></a>

This section provides step-by-step instructions for configuring AWS Elemental MediaTailor dynamic ad insertion with a content delivery network (CDN) to optimize your video monetization workflow.

For advanced ad server configuration using dynamic variables, see [MediaTailor dynamic ad variables for ADS requests](variables.md). For information about passing parameters through CDNs for ad targeting, see [MediaTailor manifest query parameters](manifest-query-parameters.md).

For conceptual information about SSAI with CDNs, see [Understand ad insertion architecture for CDN and MediaTailor integrations](ssai-cdn-architecture-overview.md).

## Prerequisites
<a name="prerequisites-ad-insertion-cdn"></a>

Before setting up ad insertion with a CDN, ensure you have:
+ An active AWS Elemental MediaTailor configuration
+ A content origin server delivering HLS or DASH content with appropriate ad markers

  For information about ad markers, see [Understanding ad insertion behavior](ad-behavior.md).
+ An ad decision server (ADS) that supports VAST or VMAP for ad targeting
+ A CDN account (such as Amazon CloudFront or another CDN provider)
+ Basic knowledge of manifest manipulation and dynamic ad insertion concepts

## Step 1: Configure CDN caching for optimal ad delivery
<a name="configure-cdn-caching"></a>

Proper CDN caching configuration is critical for optimal performance of your video monetization workflow. The caching requirements differ between server-side ad insertion (SSAI) and server-guided ad insertion (SGAI). Use these recommended settings to ensure efficient delivery of both content and personalized advertising:

### SSAI CDN caching settings
<a name="ssai-caching-settings"></a>

For server-side ad insertion workflows, proper caching configuration is critical for optimal performance. SSAI requires specific TTL values and cache key settings to ensure personalized manifests are not cached while segments are cached efficiently.

For detailed SSAI caching settings including TTL values, path patterns, and cache key configurations, see [Server-side ad insertion (SSAI) caching](cdn-optimize-caching.md#ssai-caching-optimization) in the CDN optimization guide.

Key caching principles for SSAI:
+ **Manifests**: Set TTL to 0 seconds to prevent caching of personalized content
+ **Segments**: Cache aggressively (24\$1 hours) to reduce origin load
+ **Cache keys**: Include all query parameters for manifests, URL path only for segments

### SGAI CDN caching settings
<a name="sgai-caching-settings"></a>

For server-guided ad insertion workflows, caching requirements differ from SSAI because SGAI manifests can be cached for short periods while still providing personalized ad experiences.

For comprehensive SGAI caching settings including VOD and live TTL values, see the optimization guide's caching tables. SGAI allows for better cache efficiency than SSAI while maintaining ad personalization capabilities.

Key SGAI caching differences:
+ **Manifests**: Can be cached for short periods (5-30 minutes for VOD, 2-10 seconds for live)
+ **Segments**: Cache aggressively like SSAI (24\$1 hours for most content)
+ **Performance benefit**: Better cache hit ratios than SSAI due to cacheable manifests

For Amazon CloudFront, you can implement these settings using cache behaviors with different TTL values and cache key policies. For other CDNs, refer to their specific documentation for implementing similar caching rules.

## Step 2: Implement hybrid approaches (if needed)
<a name="implement-hybrid-approach"></a>

If your architecture requires a hybrid approach with a separate CDN or caching layer between the content origin and MediaTailor:

1. Implement clear separation of concerns in your CDN configuration.

1. Configure specific CDN settings to prevent the technical issues described in the previous section.

1. Thoroughly test your configuration to verify that manifest personalization functions correctly.

1. Monitor performance metrics to ensure optimal delivery of multivariant playlists, media playlists, MPDs, and segments.

When implementing a hybrid approach, consider these specific configurations:
+ For the CDN between content origin and MediaTailor:
  + Configure compression passthrough for manifest files to preserve the original compression state from your origin
  + Include all query parameters in the cache key
  + Set short TTL values for live content manifests
+ For the CDN between MediaTailor and viewers:
  + Configure longer cache times for ad segments
  + Set appropriate TTLs for personalized manifests
  + Implement proper origin routing for content vs. ad segments

## Step 3: Complete your CDN setup
<a name="complete-cdn-setup"></a>

After choosing your architecture and understanding the request flow, complete your setup by following the detailed configuration steps in [Set up CDN integration](cdn-configuration.md).

For specific CDN providers, refer to these additional resources:
+ Amazon CloudFront: See [CloudFront integration](cloudfront-specific-recommendations.md) for CloudFront-specific configuration steps
+ Other CDNs: Apply the general principles outlined in this guide, adapting them to your specific CDN's configuration options

## Step 4: Verify your configuration
<a name="verification-steps"></a>

After completing your CDN setup, verify that your dynamic ad insertion workflow is functioning correctly:

1. Test playback through your CDN with a sample player

1. Verify that personalized advertising is inserted correctly at designated ad break points

1. Check CDN logs to confirm proper request routing

1. Monitor cache hit rates to ensure optimal performance for both content and ad segments

1. Confirm that ad targeting parameters are being properly passed through the workflow

For comprehensive testing and validation procedures, see [Testing and validation for CDN and MediaTailor integrations](cdn-integration-testing.md). For detailed information on monitoring your SSAI implementation, see [Monitor operations for CDN and MediaTailor integrations](ssai-cdn-monitor.md). To optimize performance, see [Optimize performance for CDN and MediaTailor integrations](ssai-cdn-performance.md).

# Integrate MediaTailor SSAI with channel assembly for monetized linear channels
<a name="ssai-ca-integration"></a>

This topic explains how to combine AWS Elemental MediaTailor server-side ad insertion with channel assembly and content delivery network (CDN) integration. This integration enables you to:
+ Create monetized linear channels with personalized advertising
+ Deliver targeted ads to different viewers watching the same content
+ Maintain broadcast-quality viewing experiences

## Benefits of combining SSAI with channel assembly
<a name="ssai-ca-integration-benefits"></a>

Integrating SSAI with channel assembly provides several key benefits:

Monetization of linear channels  
Insert personalized ads into your linear channels to generate revenue from your content library. You can monetize both live and VOD content within a single linear stream.

Personalized advertising  
Deliver different ads to different viewers watching the same channel content. This targeted approach increases ad relevance and potential revenue compared to traditional broadcast advertising.

Simplified ad break management  
Define ad break points in your channel assembly programs without needing to condition the content with SCTE-35 markers. This makes it easier to insert ads at natural break points in your content.

Broadcast-quality experience  
MediaTailor maintains a high-quality viewing experience with seamless transitions between content and ads. Server-side ad insertion eliminates many common issues such as:  
+ Buffering during ad transitions
+ Ad blockers preventing monetization
+ Inconsistent playback quality

Scalable delivery  
When combined with a CDN, this integration can scale to millions of concurrent viewers without degradation in performance or personalization capabilities.

## Architecture overview
<a name="ssai-ca-integration-architecture"></a>

The architecture for combining SSAI with channel assembly typically involves these components:
+ Channel assembly: Creates linear channels from VOD and live content, and inserts slate content that creates ad markers in the generated manifest
+ Ad insertion: Recognizes ad break points and inserts URLs pointing to personalized ad segments in the manifest
+ Ad decision server (ADS): Determines which ads to insert for each viewer
+ Content delivery network (CDN): Delivers the assembled content and ad segments to viewers
+ Origin server: Stores the VOD and live content segments

In this architecture:

1. Channel assembly creates a linear channel from your VOD and live content, and inserts slate content that creates the ad markers in the generated manifest

1. When a viewer requests the channel, ad insertion recognizes the ad breaks that were inserted into the linear channel

1. Ad insertion makes the call to the ADS to receive the list of ads, transcodes them, and inserts URLs pointing to the transcoded ad segments into the personalized manifest

1. The CDN delivers the personalized stream to the viewer

The following diagram illustrates this workflow:

![\[Diagram showing CDN integration with both channel assembly and ad insertion\]](http://docs.aws.amazon.com/mediatailor/latest/ug/images/ca-ssai-comb-cdn.png)


## Setting up the integration
<a name="ssai-ca-integration-setup"></a>

To set up SSAI with channel assembly:

1. Configure your edge CDN to accept manifest requests from viewers and forward them to AWS Elemental MediaTailor ad insertion.

1. Set up MediaTailor ad insertion to forward requests to your origin CDN.

1. Configure your origin CDN to forward requests to MediaTailor channel assembly.

1. Set up MediaTailor channel assembly to generate dynamic manifests based on the current schedule.

1. Configure your origin CDN to forward the assembled manifests to MediaTailor ad insertion.

1. Set up MediaTailor ad insertion to request ad decisions from your ad decision server at ad break points.

1. Configure MediaTailor ad insertion to personalize manifests by replacing the ad markers (from channel assembly) with URLs pointing to targeted ad segments (from the ADS).

1. Set up your edge CDN to deliver personalized manifests to viewers.

1. Configure your CDN architecture to handle both content and ad segment requests efficiently.

## Defining ad breaks in channel assembly
<a name="ssai-ca-integration-adbreaks"></a>

When creating programs in channel assembly, you can define ad breaks in several ways:

Program transitions  
Insert ads between programs in your channel schedule. This is the simplest approach and ensures ads don't interrupt program content.

SCTE-35 markers  
If your VOD content contains SCTE-35 markers, channel assembly can preserve these markers, and ad insertion can use them as ad break points.

Time-based insertion  
Define ad breaks at specific time points within programs. This allows you to insert ads at natural break points in your content.

For detailed information on creating programs with ad breaks, see [Working with programs](https://docs.aws.amazon.com/mediatailor/latest/ug/channel-assembly-programs.html).

## CDN caching considerations
<a name="ssai-ca-integration-caching"></a>

For optimal performance when combining channel assembly and SSAI with a CDN:
+ Configure cache behaviors that distinguish between channel assembly and SSAI requests
+ Set appropriate TTL values for manifests and segments as recommended in [Step 1: Configure CDN caching for optimal ad delivery](configuring-ssai-cdn.md#configure-cdn-caching)
+ Ensure proper routing between channel assembly, ad insertion, and your CDN origins
+ Monitor the performance metrics for both channel assembly and ad insertion components


**Recommended caching settings for combined implementation**  

| Content type | TTL | Cache key elements | 
| --- | --- | --- | 
| Channel assembly manifests | 0 seconds | URL path \$1 query parameters | 
| SSAI personalized manifests | 0 seconds | URL path \$1 all query parameters | 
| Content segments | 24\$1 hours | URL path only | 
| Ad segments | 24\$1 hours | URL path only | 

## Monitoring the integrated solution
<a name="ssai-ca-integration-monitoring"></a>

To ensure your integrated solution is performing optimally, monitor these key metrics:

Channel assembly metrics  
Monitor manifest generation time, program transitions, and any errors in the channel assembly process.

Ad insertion metrics  
Track ad fill rate, ad decision server response times, and ad insertion errors.

CDN metrics  
Monitor cache hit rates, origin request volume, and response latency for both content and ad segments.

Viewer experience metrics  
Track rebuffering events, startup times, and viewer engagement, especially during ad transitions.

For detailed information on monitoring, see [Monitor operations for CDN and MediaTailor integrations](ssai-cdn-monitor.md) and [Monitor MediaTailor channel assembly CDN operations](ca-cdn-monitor.md).

## Troubleshooting common issues
<a name="ssai-ca-integration-troubleshooting"></a>

When troubleshooting issues with the integrated solution, consider these common problems:

Ad break synchronization issues  
If ads are not appearing at the expected break points, verify that the ad break definitions in your channel assembly programs are correctly configured and that ad insertion is properly identifying these break points.

Manifest delivery errors  
If viewers are experiencing playback issues, check that the CDN is correctly forwarding manifest requests between channel assembly and ad insertion, and that the cache settings are appropriate for the dynamic nature of these manifests.

Segment routing problems  
If content or ad segments are not loading, verify that the CDN is correctly routing segment requests to the appropriate origins and that the segment URLs in the manifests are correctly formatted.

Performance degradation  
If viewers are experiencing buffering or high latency, check the CDN cache hit rates and origin request volumes to identify potential bottlenecks in the delivery pipeline.

For more troubleshooting guidance, see [Troubleshoot MediaTailor SSAI with CDNs for uninterrupted ad delivery](troubleshooting-ssai-cdn.md).

## Best practices
<a name="ssai-ca-integration-best-practices"></a>

Follow these best practices for a successful integration of SSAI with channel assembly:
+ **Test thoroughly**: Test the integrated solution with various content types, ad scenarios, and viewer conditions before deploying to production.
+ **Monitor continuously**: Set up comprehensive monitoring and alerting to quickly identify and address any issues that arise.
+ **Optimize caching**: Regularly review and adjust your CDN caching settings based on actual usage patterns and performance metrics.
+ **Plan for scale**: Design your architecture to handle peak traffic loads, especially for popular channels or events.
+ **Consider redundancy**: Implement redundancy in critical components to ensure high availability of your linear channels.
+ **Optimize ad transitions**: Ensure smooth transitions between content and ads by using consistent encoding profiles and segment durations.

## Related information
<a name="ssai-ca-integration-related"></a>

For more information about integrating SSAI with channel assembly, see:

Channel assembly documentation  
[Using AWS Elemental MediaTailor to create linear assembled streams](channel-assembly.md) - Learn about channel assembly concepts  
[Channel assembly with CDN](ca-cdn-wflw.md) - Set up channel assembly with a CDN

SSAI documentation  
[Ad insertion with CDN](ssai-cdn-workflow.md) - Set up ad insertion with a CDN  
[Understand ad insertion architecture for CDN and MediaTailor integrations](ssai-cdn-architecture-overview.md) - Understand ad insertion CDN architecture

CDN configuration  
[Set up CDN integration](cdn-configuration.md) - General CDN configuration guidance  
[CloudFront integration](cloudfront-specific-recommendations.md) - CloudFront specific configuration

# Optimize performance for CDN and MediaTailor integrations
<a name="ssai-cdn-performance"></a>

Maximize the performance of your AWS Elemental MediaTailor ad insertion implementation by optimizing your content delivery network (CDN) configuration. These settings ensure efficient content delivery and optimal viewer experience.

For detailed caching and routing optimization guidance specific to SSAI implementations, see [CDN performance optimization](cdn-optimization.md). The consolidated optimization guide provides comprehensive caching settings, request routing configuration, and performance benchmarks that apply to all MediaTailor CDN integrations.

## Common performance challenges
<a name="ssai-cdn-performance-challenges"></a>

SSAI implementations with CDNs can face several performance challenges:

Manifest manipulation overhead  
MediaTailor performs real-time manifest manipulation, which can introduce latency if not optimized properly. The following can introduce latency:  
+ Processing time for ad decision server (ADS) requests
+ Time required to modify manifests with ad segment references
+ Additional processing for personalization

Cache efficiency issues  
Personalized manifests can reduce CDN cache efficiency because:  
+ Each viewer may receive a unique manifest
+ Session parameters can fragment the cache
+ Dynamic content requires careful cache configuration

Origin load spikes  
Improper caching can lead to origin load spikes during:  
+ High-traffic events
+ Cache refreshes
+ CDN configuration changes

Ad-related playback issues  
Ad insertion can cause playback disruptions such as:  
+ Buffering during ad transitions
+ Quality differences between content and ads
+ Playback failures when ads cannot be retrieved

For comprehensive performance optimization guidance including caching strategies, request routing, performance benchmarks, and advanced optimization techniques, see [CDN performance optimization](cdn-optimization.md). The consolidated optimization guide provides detailed settings and benchmarks that apply to all MediaTailor CDN integrations, including SSAI implementations.

## Best practices summary
<a name="ssai-cdn-performance-best-practices"></a>

Follow these best practices to ensure optimal SSAI performance with CDNs:

Architecture best practices  
+ Choose the right architectural pattern for your scale and requirements
+ Deploy services in close proximity to minimize latency
+ Implement redundancy for critical components

Caching best practices  
+ Use different caching strategies for different content types
+ Optimize cache keys to balance personalization and efficiency
+ Set appropriate TTLs based on content type and update frequency. For detailed TTL recommendations, see [Caching optimization for CDN and MediaTailor integrations](cdn-optimize-caching.md).

Ad delivery best practices  
+ Optimize ADS interactions with timeouts and fallbacks
+ Prepare ads to match content specifications
+ Implement efficient ad segment delivery

Monitoring best practices  
+ Monitor all components of your SSAI implementation
+ Set up alerts for performance degradation
+ Regularly review and optimize your configuration

## Complete optimization guidance
<a name="ssai-optimization-reference"></a>

For comprehensive CDN optimization guidance including detailed caching strategies, request routing configuration, performance benchmarks, and advanced optimization techniques, see [CDN performance optimization](cdn-optimization.md). The consolidated optimization guide provides complete settings and benchmarks that apply to all MediaTailor CDN integrations, including SSAI implementations.

# Monitor operations for CDN and MediaTailor integrations
<a name="ssai-cdn-monitor"></a>

AWS Elemental MediaTailor provides robust analytics capabilities that, when combined with content delivery network (CDN) metrics, offer comprehensive insights into your SSAI implementation. This topic covers:

For comprehensive CDN monitoring guidance including essential metrics, monitoring tools setup, alert configuration, and troubleshooting strategies that apply to all MediaTailor implementations, see [CDN monitoring](cdn-monitoring.md). This topic focuses on SSAI-specific monitoring requirements and ad insertion analytics.
+ Monitoring strategies for SSAI and CDN integration
+ Analytics tools and data collection methods
+ Data-driven optimization techniques

## Key metrics for SSAI with CDNs
<a name="ssai-cdn-monitor-metrics"></a>

To effectively monitor your SSAI implementation with CDNs, track these essential metrics:

Ad insertion metrics  
**Ad fill rate**: The percentage of ad opportunities that were successfully filled with ads.  
**Ad error rate**: The percentage of ad requests that resulted in errors.  
**Ad response time**: How long it takes for the ad decision server to respond to ad requests.  
**Ad duration accuracy**: How closely the actual duration of inserted ads matches the expected duration.

Viewer experience metrics  
**Rebuffering ratio**: The percentage of viewing time spent buffering.  
**Start-up time**: How long it takes for video playback to begin.  
**Ad transition smoothness**: How seamlessly the player transitions between content and ads.  
**Session duration**: How long viewers watch before abandoning the stream.

## Analytics tools and integration
<a name="ssai-cdn-monitor-tools"></a>

Combine these tools to create a comprehensive analytics solution for your SSAI implementation:

AWS Elemental MediaTailor server-side metrics  
MediaTailor provides built-in metrics through Amazon CloudWatch that track ad requests, responses, and errors. These metrics can be viewed in the CloudWatch console or integrated into custom dashboards.  
Key MediaTailor metrics include:  
+ `AdDecisionServer.Ads`: The number of ads returned by the ad decision server.
+ `AdDecisionServer.Duration`: The total duration of ads returned by the ad decision server.
+ `AdDecisionServer.Errors`: The number of errors returned by the ad decision server.
+ `AdDecisionServer.Latency`: The response time of the ad decision server.
For a complete list of MediaTailor metrics, see [Monitoring MediaTailor with Amazon CloudWatch](https://docs.aws.amazon.com/mediatailor/latest/ug/monitoring-cloudwatch.html).

CDN analytics  
CDN providers offer detailed analytics on content delivery performance. For Amazon CloudFront, use CloudWatch metrics and Amazon CloudFront access logs to analyze delivery patterns.  
Important CDN metrics to monitor:  
+ Request count by content type (manifests vs. segments)
+ Cache hit ratio for different content types
+ Geographic distribution of viewers
+ Error rates by error code

Client-side tracking  
Implement client-side tracking to gather viewer experience metrics that aren't available server-side:  
+ Player events (play, pause, seek, buffer)
+ Ad view completion rates
+ Quality of service metrics (resolution changes, bitrate)
+ Viewer engagement patterns
Consider using MediaTailor client-side tracking to collect and report these metrics.

Integrated dashboards  
Create comprehensive dashboards that combine metrics from multiple sources:  
+ Use CloudWatch dashboards to combine MediaTailor and CloudFront metrics
+ Consider third-party analytics platforms for more advanced visualization
+ Set up cross-service correlation to identify relationships between metrics

## Implementing a monitoring strategy
<a name="ssai-cdn-monitor-implementation"></a>

Follow these steps to implement a comprehensive monitoring strategy for your SSAI with CDN implementation:

1. **Set up basic monitoring**
   + Enable CloudWatch metrics for MediaTailor
   + Configure CDN logging and metrics collection
   + Implement client-side tracking in your video player

1. **Create custom dashboards**
   + Build a CloudWatch dashboard that combines key metrics
   + Include visualizations for ad fill rate, CDN performance, and viewer experience
   + Add annotations for important events (configuration changes, major broadcasts)

1. **Configure alerts**
   + Set up CloudWatch alarms for critical metrics
   + Create composite alarms that trigger on multiple related conditions
   + Configure notification channels (email, SMS, Amazon SNS)

1. **Implement automated responses**
   + Use CloudWatch Events to trigger automated responses to common issues
   + Create runbooks for manual intervention when needed
   + Document troubleshooting procedures for different alert scenarios

**Example Creating a comprehensive SSAI monitoring dashboard**  
This example shows how to create a CloudWatch dashboard that combines MediaTailor and CloudFront metrics:  

```
{
  "widgets": [
    {
      "type": "metric",
      "properties": {
        "metrics": [
          [ "AWS/MediaTailor", "AdDecisionServer.Ads", "Configuration", "your-config-name" ],
          [ ".", "AdDecisionServer.Errors", ".", "." ]
        ],
        "period": 300,
        "stat": "Sum",
        "region": "us-west-2",
        "title": "Ad Decision Server Performance"
      }
    },
    {
      "type": "metric",
      "properties": {
        "metrics": [
          [ "AWS/CloudFront", "Requests", "DistributionId", "your-distribution-id" ],
          [ ".", "4xxErrorRate", ".", "." ],
          [ ".", "5xxErrorRate", ".", "." ]
        ],
        "period": 300,
        "stat": "Average",
        "region": "us-east-1",
        "title": "CDN Performance"
      }
    }
  ]
}
```

## Data-driven optimization
<a name="ssai-cdn-monitor-optimization"></a>

Use the analytics data you collect to optimize your SSAI implementation:

CDN cache optimization  
Analyze cache hit ratios to identify opportunities for improvement:  
+ Adjust TTL settings based on content type and update frequency. For detailed TTL recommendations, see [Step 1: Configure CDN caching for optimal ad delivery](configuring-ssai-cdn.md#configure-cdn-caching).
+ Optimize cache key settings to improve cache efficiency
+ Consider implementing origin shield for multi-layered caching

Ad delivery optimization  
Use ad performance metrics to improve ad delivery:  
+ Identify and address common ad insertion errors
+ Optimize ad decision server response times
+ Adjust ad targeting parameters based on fill rate analysis

Viewer experience optimization  
Improve the viewer experience based on client-side metrics:  
+ Analyze drop-off patterns during ad breaks
+ Optimize ad transition points for smoother playback
+ Adjust ad frequency and duration based on viewer engagement data

Cost optimization  
Balance performance and cost considerations:  
+ Analyze bandwidth usage patterns to optimize CDN costs
+ Consider price class adjustments for CloudFront distributions
+ Evaluate the cost-benefit of different caching strategies

## Best practices
<a name="ssai-cdn-monitor-best-practices"></a>

Follow these best practices for effective SSAI monitoring and analytics:
+ **Establish baselines**: Collect metrics during normal operation to establish performance baselines that can be used for comparison during troubleshooting.
+ **Implement multi-level monitoring**: Monitor at different levels of your architecture (origin, CDN, player) to get a complete picture of performance.
+ **Correlate metrics across services**: Look for relationships between metrics from different services to identify root causes of issues.
+ **Use anomaly detection**: Implement CloudWatch anomaly detection to automatically identify unusual patterns in your metrics.
+ **Regularly review and refine**: Schedule regular reviews of your monitoring strategy and adjust based on changing requirements and new insights.
+ **Document findings and actions**: Maintain a record of optimization efforts and their results to build institutional knowledge.

## Related information
<a name="ssai-cdn-monitor-related"></a>

For more information about monitoring and analytics for SSAI with CDNs, see:
+ [Optimize performance for CDN and MediaTailor integrations](ssai-cdn-performance.md) for performance optimization techniques
+ [Troubleshoot MediaTailor SSAI with CDNs for uninterrupted ad delivery](troubleshooting-ssai-cdn.md) for troubleshooting common issues
+ [Monitoring MediaTailor with Amazon CloudWatch](https://docs.aws.amazon.com/mediatailor/latest/ug/monitoring-cloudwatch.html) for detailed information about MediaTailor metrics
+ [Viewing CloudFront and edge function metrics](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/viewing-cloudfront-metrics.html) for information about CloudFront metrics

# Troubleshoot MediaTailor SSAI with CDNs for uninterrupted ad delivery
<a name="troubleshooting-ssai-cdn"></a>

This section provides solutions for common issues when using AWS Elemental MediaTailor dynamic ad insertion with a content delivery network (CDN). These solutions will help you troubleshoot problems with your video monetization through personalized advertising.

For comprehensive CDN troubleshooting guidance including cache performance issues, HTTP error resolution, testing procedures, and diagnostic techniques that apply to all MediaTailor implementations, see [Troubleshoot CDN integration](cdn-troubleshooting.md). This section focuses on SSAI-specific troubleshooting requirements and ad insertion issues.

If you encounter issues with your CDN and SSAI setup, check these common problems:

Personalized advertising not appearing in stream  
Verify that your ADS responds correctly and that AWS Elemental MediaTailor communicates with it. Check these potential issues:  
+ Ad targeting query parameters not properly forwarded through your CDN
+ Ad break points incorrectly defined in your content
+ ADS connectivity or response problems

Playback errors at ad break points  
Ensure that ad segments are properly transcoded to match your content bitrates and resolutions. Check these common issues:  
+ CDN incorrectly routing requests for ad segments
+ Manifest manipulation errors at transition points
+ Mismatched encoding profiles between content and ads

Stale manifests  
For live content, verify that your CDN cache TTL settings are appropriate. For personalized manifests, use TTL of 0 seconds. Consider implementing cache invalidation for rapidly changing manifests. For comprehensive TTL guidance, see [Caching optimization for CDN and MediaTailor integrations](cdn-optimize-caching.md).

High latency  
Check your CDN configuration for optimal routing. Ensure that your CDN has edge locations near your viewers for best performance.

## Advanced troubleshooting
<a name="advanced-troubleshooting"></a>

For more complex issues, try these advanced troubleshooting techniques:

Inconsistent ad targeting behavior  
Check for query parameter inconsistencies between player requests and ADS requests. Ensure all required targeting parameters are properly passed through the CDN.

CDN cache inconsistencies  
Verify cache key configurations to ensure proper content differentiation. Consider implementing cache purging for critical manifest updates.

Ad tracking failures  
Check that beacon URLs are properly forwarded and not blocked by the CDN. Verify that client players can reach the tracking endpoints.

## Performance optimization
<a name="performance-optimization"></a>

To optimize the performance of your dynamic ad insertion and video monetization workflow:
+ Fine-tune TTL settings based on content type and viewer patterns. For detailed TTL recommendations, see [Caching optimization for CDN and MediaTailor integrations](cdn-optimize-caching.md).
+ Implement geographic routing to minimize latency for global audiences
+ Consider using multiple CDNs for redundancy and optimal performance
+ Monitor cache hit ratios and adjust configurations accordingly
+ Optimize manifest manipulation processes to reduce processing time at ad break points
+ Pre-transcode ads to match common content profiles for seamless personalized advertising insertion

### Performance benchmarks
<a name="performance-benchmarks"></a>

When optimizing your AWS Elemental MediaTailor ad insertion CDN integration, aim for these performance benchmarks:

Cache Hit Ratio Targets  
Content segments: greater than 95% cache hit ratio  
Ad segments: greater than 90% cache hit ratio  
Manifests: Not applicable (should not be cached for personalized ad insertion)

Latency Benchmarks  
Manifest request latency: less than 100ms (P95)  
Content segment delivery: less than 50ms (P95)  
Ad segment delivery: less than 75ms (P95)  
End-to-end startup time: less than 2 seconds

Origin Load Metrics  
Origin requests per viewer: less than 0.1 requests per minute per viewer  
Origin bandwidth per viewer: less than 5% of total viewer bandwidth

Error Rate Targets  
Manifest errors: less than 0.1%  
Segment errors: less than 0.01%  
Player-reported rebuffering: less than 1%

Scalability Benchmarks  
Support for 10 times the normal traffic during peak events without degradation  
Ability to handle greater than 1000 requests per second per channel

Use Amazon CloudWatch metrics to track these performance indicators. For detailed monitoring instructions, see [Monitoring AWS Elemental MediaTailor with Amazon CloudWatch metrics](monitoring-cloudwatch-metrics.md).

## Related information
<a name="ssai-cdn-related"></a>

For more information about ad insertion with CDNs, see:

Ad insertion documentation  
[Getting started with MediaTailor ad insertion](getting-started-ad-insertion.md) - Learn about ad insertion concepts  
[Setting up](setting-up.md) - Get started with ad insertion

CDN integration  
[Set up CDN integration](cdn-configuration.md) - General CDN configuration guidance  
[CloudFront integration](cloudfront-specific-recommendations.md) - CloudFront specific configuration

Channel assembly integration  
[Channel assembly with CDN](ca-cdn-wflw.md) - Learn about channel assembly with CDNs  
[Implement ad insertion](ca-cdn-setup-advanced.md) - Implement ad insertion with channel assembly

Monitoring and optimization  
[Monitor operations for CDN and MediaTailor integrations](ssai-cdn-monitor.md) - Comprehensive monitoring and analytics  
[Optimize performance for CDN and MediaTailor integrations](ssai-cdn-performance.md) - Performance optimization guide  
[Monitoring AWS Elemental MediaTailor with Amazon CloudWatch metrics](monitoring-cloudwatch-metrics.md) - CloudWatch metrics for MediaTailor