Skip to content

Commit 2afc636

Browse files
authored
Merge pull request #104577 from Juliako/cdn
added cdn prefetch
2 parents 4a5c40d + 9cd7263 commit 2afc636

File tree

3 files changed

+168
-33
lines changed

3 files changed

+168
-33
lines changed

articles/media-services/latest/TOC.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@
9999
- name: Streaming Endpoints
100100
displayName: origin, packager, cdn
101101
href: streaming-endpoint-concept.md
102+
- name: Scaling streaming with CDN
103+
href: scale-streaming-cdn.md
102104
- name: Streaming Locators
103105
displayName: URLs
104106
href: streaming-locators-concept.md
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
---
2+
# Mandatory fields. See more on aka.ms/skyeye/meta.
3+
title: Scaling streaming with cdn
4+
titleSuffix: Azure Media Services
5+
description: Learn about a streaming service that delivers content directly to a client player app or to a Content Delivery Network (CDN).
6+
services: media-services
7+
documentationcenter: ''
8+
author: Juliako
9+
manager: femila
10+
editor: ''
11+
12+
ms.service: media-services
13+
ms.workload:
14+
ms.topic: article
15+
ms.date: 02/13/2020
16+
ms.author: juliako
17+
---
18+
19+
# Scaling streaming with CDN
20+
21+
Azure Content Delivery Network (CDN) offers developers a global solution for rapidly delivering high-bandwidth content to users by caching their content at strategically placed physical nodes across the world.
22+
23+
CDN caches content streamed from a Media Services [streaming endpoint (origin)](streaming-endpoint-concept.md) per codec, per streaming protocol, per bitrate, per container format, and per encryption/DRM. For each combination of codec-streaming protocol-container format-bitrate-encryption, there will be a separate CDN cache.
24+
25+
The popular content will be served directly from the CDN cache as long as the video fragment is cached. Live content is likely to be cached because you typically have many people watching the exact same thing. On-demand content can be a bit trickier because you could have some content that's popular and some that isn't. If you have millions of video assets where none of them are popular (only one or two viewers a week) but you have thousands of people watching all different videos, the CDN becomes much less effective.
26+
27+
You also need to consider how adaptive streaming works. Each individual video fragment is cached as it's own entity. For example, imagine the first time a certain video is watched. If the viewer skips around watching only a few seconds here and there, only the video fragments associated with what the person watched get cached in CDN. With adaptive streaming, you typically have 5 to 7 different bitrates of video. If one person is watching one bitrate and another person is watching a different bitrate, then they're each cached separately in the CDN. Even if two people are watching the same bitrate, they could be streaming over different protocols. Each protocol (HLS, MPEG-DASH, Smooth Streaming) is cached separately. So each bitrate and protocol are cached separately and only those video fragments that have been requested are cached.
28+
29+
When deciding whether or not to enable CDN on the Media Services [streaming endpoint](streaming-endpoint-concept.md), consider the number of anticipated viewers. CDN helps only if you are anticipating many viewers for your content. If the max concurrency of viewer is lower than 500, it's recommended to disable CDN since CDN scales best with concurrency.
30+
31+
This topic discusses enabling [CDN integration](#enable-azure-cdn-integration). It also explains prefetching (active caching) and the [Origin-Assist CDN-Prefetch](#origin-assist-cdn-prefetch) concept.
32+
33+
## Considerations
34+
35+
* The [streaming endpoint](streaming-endpoint-concept.md) `hostname` and the streaming URL remain the same whether or not you enable CDN.
36+
* If you need the ability to test your content with or without CDN, create another streaming endpoint that isn't CDN enabled.
37+
38+
## Enable Azure CDN integration
39+
40+
> [!IMPORTANT]
41+
> You cannot enable CDN for trial or student Azure accounts.
42+
>
43+
> CDN integration is enabled in all the Azure data centers except Federal Government and China regions.
44+
45+
After a streaming endpoint is provisioned with CDN enabled, there's a defined wait time on Media Services before DNS update is done to map the streaming endpoint to CDN endpoint.
46+
47+
If you later want to disable/enable the CDN, your streaming endpoint must be in the **stopped** state. It could take up to two hours for the Azure CDN integration to get enabled and for the changes to be active across all the CDN POPs. However, you can start your streaming endpoint and stream without interruptions from the streaming endpoint and once the integration is complete, the stream is delivered from the CDN. During the provisioning period, your streaming endpoint will be in the **starting** state and you might observe degraded performance.
48+
49+
When the Standard streaming endpoint is created, it's configured by default with Standard Verizon. You can configure Premium Verizon or Standard Akamai providers using REST APIs.
50+
51+
Azure Media Services integration with Azure CDN is implemented on **Azure CDN from Verizon** for standard streaming endpoints. Premium streaming endpoints can be configured using all **Azure CDN pricing tiers and providers**.
52+
53+
> [!NOTE]
54+
> For details about Azure CDN, see the [CDN overview](../../cdn/cdn-overview.md).
55+
56+
## Determine if a DNS change was made
57+
58+
You can determine if DNS change was made on a streaming endpoint (the traffic is being directed to the Azure CDN) by using https://www.digwebinterface.com. If you see azureedge.net domain names in the results, the traffic is now being pointed to the CDN.
59+
60+
## Origin-Assist CDN-Prefetch
61+
62+
CDN caching is a reactive process. If CDN can predict what the next object will be requested, CDN can pro-actively request and cache the next object. With this process, you can achieve a cache-hit for all (or most) of the objects, hence improving performance.
63+
64+
The concept of prefetching strives to position objects at the "Edge of the Internet" in anticipation that these will be requested by the player imminently, thereby reducing the time to deliver that object to the player.
65+
66+
To achieve this goal, a streaming endpoint (origin) and CDN need to work hand in hand:
67+
68+
- The Media Services origin needs to have the “intelligence” (Origin-Assist) to inform CDN the next object to prefetch, and
69+
- CDN does the prefetch and caching (CDN-Prefetch part). CDN also needs to have the “intelligence” to inform the origin whether it is a prefetch or a regular fetch, handling 404 responses and a way to avoid endless prefetch loop.
70+
71+
### Benefits
72+
73+
The benefits of the *Origin-Assist CDN-Prefetch* feature includes:
74+
75+
- Prefetch improves video playback quality by: pre-positioning anticipated video segments at the edge during playback, reducing latency to the viewer and improving video segment download times. This results in faster video start-up time and lower rebuffering occurrences.
76+
- This concept is applicable to general CDN-origin scenario, not limited to media.
77+
- Akamai has added this feature to [Akamai Cloud Embed (ACE)](https://learn.akamai.com/en-us/products/media_delivery/cloud_embed.html).
78+
79+
> [!NOTE]
80+
> This feature is not yet applicable to the Akamai CDN integrated with Media Services streaming endpoint. However, it is available for Media Services customers that have a pre-existing Akamai contract and require custom integration between Akamai CDN and the Media Services origin.
81+
82+
### How it works
83+
84+
CDN support for the *Origin-Assist CDN-Prefetch* headers (for both live and video on-demand streaming) is available to customers who have direct contract with Akamai CDN. The feature involves the following HTTP header exchanges between Akamai CDN and the Media Services origin:
85+
86+
|HTTP header|Values|Sender|Receiver|Purpose|
87+
| ---- | ---- | ---- | ---- | ----- |
88+
|CDN-Origin-Assist-Prefetch-Enabled | 1 (default) or 0 |CDN|Origin|To indicate CDN is prefetch enabled|
89+
|CDN-Origin-Assist-Prefetch-Path| Example: <br/>Fragments(video=1400000000,format=mpd-time-cmaf)|Origin|CDN|To provide prefetch path to CDN|
90+
|CDN-Origin-Assist-Prefetch-Request|1 (prefetch request) or 0 (regular request)|CDN|Origin|To indicate the request from CDN is a prefetch|
91+
92+
To see part of the header exchange in action, you can try the following steps:
93+
94+
1. Use Postman or curl to issue a request to the Media Services origin for an audio or video segment or fragment. Make sure to add the header CDN-Origin-Assist-Prefetch-Enabled: 1 in the request.
95+
2. In the response, you should see the header CDN-Origin-Assist-Prefetch-Path with a relative path as its value.
96+
97+
### Supported streaming protocols
98+
99+
The *Origin-Assist CDN-Prefetch* feature supports the following streaming protocols for live and on-demand streaming:
100+
101+
* HLS v3
102+
* HLS v4
103+
* HLS CMAF
104+
* DASH (CSF)
105+
* DASH (CMAF)
106+
* Smooth streaming
107+
108+
### FAQs
109+
110+
* What if a prefetch path URL is invalid so that CDN prefetch gets a 404?
111+
112+
CDN will only cache a 404 response for 10 seconds (or other configured value).
113+
* Suppose you have an on-demand video. If CDN-prefetch is enabled, does this feature implies that once a client requests the first video segment, prefetch will start a loop to prefetch all subsequent video segments at the same bitrate?
114+
115+
No, CDN-prefetch is performed only after a client-initiated request/response. CDN-prefetch is never triggered by a prefetch, to avoid a prefetch loop.
116+
* Is Origin-Assist CDN-Prefetch feature always on? How can it be turned on/off?
117+
118+
This feature is off by default. Customers need to turn it on via Akamai API.
119+
* For live streaming, what would happen to Origin-Assist if the next segment or fragment is not yet available?
120+
121+
In this case the Media Services origin will not provide CDN-Origin-Assist-Prefetch-Path header and CDN-prefetch will not occur.
122+
* How does *Origin-Assist CDN-Prefetch* work with dynamic manifest filters?
123+
124+
This feature works independently of manifest filter. When the next fragment is out of a filter window, its URL will still be located by looking into the raw client manifest, and then returned as CDN prefetch response header. This means, CDN will get the URL of a fragment that is filtered out from DASH/HLS/Smooth manifest. However, the player will never make a GET request to CDN to fetch that fragment, because that fragment is not included in the DASH/HLS/Smooth manifest held by the player (the player doesn’t know that fragment’s existence).
125+
* Can DASH MPD/HLS playlist/Smooth manifest be prefetched?
126+
127+
No, DASH MPD, HLS master playlist, HLS variant playlist or smooth manifest URL is not added to prefetch header.
128+
* Are prefetch URLs relative or absolute?
129+
130+
While Akamai CDN allows both, the Media Services origin only provides relative URLs for prefetch path because there is no apparent benefit in using absolute URLs.
131+
* Does this feature work with DRM-protected contents?
132+
133+
Yes, since this feature works at HTTP level, it neither decodes nor parses any segment/fragment. It does not care whether the content is encrypted or not.
134+
* Does this feature work with Server Side Ad Insertion (SSAI)?
135+
136+
For original/main content (the original video content before ad insertion) works, since SSAI does not change the timestamp of the source content from the Media Services origin. Whether this feature works with ad contents, depends on whether ad origin supports Origin-Assist. For example, if ad contents are also hosted in Azure Media Services (same or separate origin), ad contents will also be prefetched.
137+
* Does this feature work with UHD/HEVC contents?
138+
139+
Yes.
140+
141+
## Ask questions, give feedback, get updates
142+
143+
Check out the [Azure Media Services community](media-services-community.md) article to see different ways you can ask questions, give feedback, and get updates about Media Services.
144+
145+
## Next steps
146+
147+
The sample [in this repository](https://github.com/Azure-Samples/media-services-v3-dotnet-quickstarts/blob/master/AMSV3Quickstarts/EncodeAndStreamFiles/Program.cs) shows how to start the default streaming endpoint with .NET.

articles/media-services/latest/streaming-endpoint-concept.md

Lines changed: 19 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ Recommended usage |Recommended for the vast majority of streaming scenarios.|Pro
7171

7272
<sup>1</sup> Only used directly on the Streaming Endpoint when the CDN isn't enabled on the endpoint.<br/>
7373

74-
## Properties
74+
## Streaming Endpoint properties
7575

7676
This section gives details about some of the Streaming Endpoint's properties. For examples of how to create a new streaming endpoint and descriptions of all properties, see [Streaming Endpoint](https://docs.microsoft.com/rest/api/media/streamingendpoints/create).
7777

@@ -128,51 +128,37 @@ This section gives details about some of the Streaming Endpoint's properties. Fo
128128

129129
- `scaleUnits`: Provide you with dedicated egress capacity that can be purchased in increments of 200 Mbps. If you need to move to a **Premium** type, adjust `scaleUnits`.
130130

131-
## Working with CDN
131+
## Why use multiple streaming endpoints?
132132

133-
In most cases, you should have CDN enabled. However, if you're anticipating max concurrency lower than 500 viewers, then it's recommended to disable CDN since CDN scales best with concurrency.
133+
A single streaming endpoint can stream both live and on-demand videos and most customers only use one streaming endpoint. This section gives some examples of why you may need to use multiple streaming endpoints.
134134

135-
### Considerations
135+
* Each reserved unit allows for 200 Mbps of bandwidth. If you need more than 2,000 Mbps (2 Gbps) of bandwidth, you could use the second streaming endpoint and load balance to give you additional bandwidth.
136136

137-
* The Streaming Endpoint `hostname` and the streaming URL remain the same whether or not you enable CDN.
138-
* If you need the ability to test your content with or without CDN, create another Streaming Endpoint that isn't CDN enabled.
137+
However, CDN is the best way to achieve scale out for streaming content but if you are delivering so much content that the CDN is pulling more than 2 Gbps then you can add additional streaming endpoints (origins). In this case you would need to hand out content URLs that are balanced across the two streaming endpoints. This approach gives better caching than trying to send requests to each origin randomly (for example, via a traffic manager).
138+
139+
> [!TIP]
140+
> Usually if the CDN is pulling more than 2 Gbps then something might be misconfigured (for example, no origin shielding).
141+
142+
* Load balancing different CDN providers. For example, you could set up the default streaming endpoint to use the Verizon CDN and create a second one to use Akamai. Then add some load balancing between the two to achieve multi-CDN balancing.
139143

140-
### Detailed explanation of how caching works
144+
However, customer often do load balancing across multiple CDN providers using a single origin.
145+
* Streaming mixed content: Live and Video on Demand.
141146

142-
There's no specific bandwidth value when adding the CDN because the amount of bandwidth that's needed for a CDN enabled streaming endpoint varies. A lot depends on the type of content, how popular it is, the bitrates, and the protocols. The CDN is only caching what's being requested. That means that popular content will be served directly from the CDN–as long as the video fragment is cached. Live content is likely to be cached because you typically have many people watching the exact same thing. On-demand content can be a bit trickier because you could have some content that's popular and some that isn't. If you have millions of video assets where none of them are popular (only one or two viewers a week) but you have thousands of people watching all different videos, the CDN becomes much less effective. With this cache misses, you increase the load on the streaming endpoint.
147+
The access patterns for live and on-demand content are very different. The live content tends to get a lot of demand for the same content all at once. The video on-demand content (long tail archive content for instance) has low usage on the same content. Thus caching works very well on the live content but not as well on the long tail content.
143148

144-
You also need to consider how adaptive streaming works. Each individual video fragment is cached as it's own entity. For example, imagine the first time a certain video is watched. If the viewer skips around watching only a few seconds here and there, only the video fragments associated with what the person watched get cached in the CDN. With adaptive streaming, you typically have 5 to 7 different bitrates of video. If one person is watching one bitrate and another person is watching a different bitrate, then they're each cached separately in the CDN. Even if two people are watching the same bitrate, they could be streaming over different protocols. Each protocol (HLS, MPEG-DASH, Smooth Streaming) is cached separately. So each bitrate and protocol are cached separately and only those video fragments that have been requested are cached.
149+
Consider a scenario in which your customers are mainly watching live content but are only occasionally watching on-demand content and it is served from the same Streaming Endpoint. The low usage of on-demand content would occupy cache space that would be better saved for the live content. In this scenario, we would recommend serving the live content from one Streaming Endpoint and the long tail content from another Streaming Endpoint. This will improve the performance of the live event content.
150+
151+
## Scaling streaming with CDN
145152

146-
### Enable Azure CDN integration
153+
See the following articles:
147154

148-
> [!IMPORTANT]
149-
> You cannot enable CDN for trial or student Azure accounts.
150-
>
151-
> CDN integration is enabled in all the Azure data centers except Federal Government and China regions.
152-
153-
After a Streaming Endpoint is provisioned with CDN enabled, there's a defined wait time on Media Services before DNS update is done to map the Streaming Endpoint to CDN endpoint.
154-
155-
If you later want to disable/enable the CDN, your streaming endpoint must be in the **stopped** state. It could take up to two hours for the Azure CDN integration to get enabled and for the changes to be active across all the CDN POPs. However, you can start your streaming endpoint and stream without interruptions from the streaming endpoint and once the integration is complete, the stream is delivered from the CDN. During the provisioning period, your streaming endpoint will be in the **starting** state and you might observe degraded performance.
156-
157-
When the Standard streaming endpoint is created, it's configured by default with Standard Verizon. You can configure Premium Verizon or Standard Akamai providers using REST APIs.
158-
159-
Azure Media Services integration with Azure CDN is implemented on **Azure CDN from Verizon** for standard streaming endpoints. Premium streaming endpoints can be configured using all **Azure CDN pricing tiers and providers**.
160-
161-
> [!NOTE]
162-
> For details about Azure CDN, see the [CDN overview](../../cdn/cdn-overview.md).
163-
164-
### Determine if DNS change was made
165-
166-
You can determine if DNS change was made on a Streaming Endpoint (the traffic is being directed to the Azure CDN) by using https://www.digwebinterface.com. If the results has azureedge.net domain names in the results, the traffic is now being pointed to the CDN.
155+
- [CDN overview](../../cdn/cdn-overview.md)
156+
- [Scaling streaming with CDN](scale-streaming-cdn.md)
167157

168158
## Ask questions, give feedback, get updates
169159

170160
Check out the [Azure Media Services community](media-services-community.md) article to see different ways you can ask questions, give feedback, and get updates about Media Services.
171161

172-
## See also
173-
174-
[CDN overview](../../cdn/cdn-overview.md)
175-
176162
## Next steps
177163

178164
The sample [in this repository](https://github.com/Azure-Samples/media-services-v3-dotnet-quickstarts/blob/master/AMSV3Quickstarts/EncodeAndStreamFiles/Program.cs) shows how to start the default streaming endpoint with .NET.

0 commit comments

Comments
 (0)