19

I am using azure blob storage to store images in a public container and embedding them in a public website. Everything works fine, blobs are publicly available on xxxxx.blob.core.windows.net the instant i upload them. I wanted to use Azure CDN for their edge caching infrastructure and set up one at xxxxx.vo.msecnd.net.

But now, when i point my images to the CDN, it returns 404 for a good 15 mins or so, then it starts serving. It's mentioned on their documentation that we should not use CDN for high violatile or frequently changing blobs, but a simple CMS with image upload feature for a public site warrants a CDN isn't it?

Lee Gary
  • 2,357
  • 2
  • 22
  • 38

4 Answers4

14

I am in exactly the same situation at the moment for product images that are uploaded to my e-commerce site. I prefer to use Azure CDN on top of Azure blob storage for all of the obvious reasons but cannot wait 15 minutes for the image to be available.

For now I have resolved to store the blob storage URL initially but then later rewrite it to use the CDN domain via an Azure WebJob running once daily. It seems like an unnecessary amount of extra work but I haven't yet found a better option and really want to use the Azure CDN.

Andy Mehalick
  • 993
  • 8
  • 19
  • I'm not sure if Microsoft themselves are using this cdn internally, if so, it's probably the same approach u did – Lee Gary Sep 18 '14 at 14:13
0

What I'm doing right now... for website related images and files I upload manually before deployment (https://abc.blob.core.windows.net/cdn) and If website User upload an image or file using my website, Internally I upload that file on blob storage (separate container not CDN) using CloudBlobClient

Pankaj Rawat
  • 4,037
  • 6
  • 41
  • 73
-1

CDN is used for static content delivery, but in your case you need dynamic content delivery via CDN. You could use Cloud Service + CDN. This makes Dynamic contents delivered from CDN using ASP.net Caching concepts.

Please refer this link for more details: Using the Windows Azure Content Delivery Network (CDN)

CreativeManix
  • 2,162
  • 1
  • 17
  • 29
  • The article suggests to implement Output Cache, it's a viable solution but it's totally out of CDN context, the server can set the header after the first request hits, but other CDN services that provides origin-pull can facilitate systems to offload requests 100% from the system, Azure CDN can do it too, but after around 15mins.. – Lee Gary Oct 13 '14 at 01:21
  • It does look like output cache. But it is not just that, It uses output cache mechanism to determine the cache policy, but the content is cached and delivered from CDN. So first request is responded from custom code, then on the content is served from CDN. However still it hits your web role, but it doesn't execute mvc/asp.net pipe line, instead Azure routes the request to CDN to fetch the content. This config is the KEY for this – CreativeManix Oct 13 '14 at 11:32
  • 1
    It's helpful but in the original question the problem is when we upload the image to cdn, when we try to view the file from CDN, it returns 404 for at least 15 mins, then it starts showing the file.. Which is not acceptable for my use case which is a custom built CMS which user expects the file to be live as soon as they click save. – Lee Gary Oct 13 '14 at 11:40
  • I have done some testing on this. It took nearly 15 to 30 min to load first image for newly created CDN. Then it works fine. I used https://geopeeker.com/ site to test the image link from different locations, all looks good. As soon as I upload Image on my storage it is appearing in CDN url. – CreativeManix Oct 17 '14 at 20:24
  • 2
    You're confusing `dynamic content` with `new but static content`. Dynamic content is where the same URI changes the content (e.g. news.html's contents). static content is where the same URI delivers the same bits (e.g. image.jpg). – DeepSpace101 Mar 25 '16 at 16:36
-2

CDN enables a user to fetch content from a CDN-POP that is geographically closest to the user thus allowing lower read latencies. Without a CDN, every request would reach the origin server (in your case Azure Storage). The low latency offered by CDN is achieved when there are cache hits. On a cache miss, a CDN-POP will fetch the content from the origin server reducing the latency benefit offered by CDN. Cache hits are usually dependent on whether the content is static (results in cache hits) or dynamic (results in cache miss) and its popularity (hot objects result in cache hit).

Your choice of using a CDN or not depends on a) whether your files are static or dynamic, if dynamic then the benefit of using a CDN is lower b) whether low latency is important to your application and c) Request rate : With low number of requests your files are likely to be cached-out so a CDN may not be that useful and d) Whether you have high scalability requirements. Note, Azure storage has the following scalability limits. If your application exceeds the scalability limits of azure storage then it is recommended to use a CDN

Palec
  • 12,743
  • 8
  • 69
  • 138
  • 6
    i know the benefits and reasons for using a cdn, but imagine this, user uploads images into my site and i put it into azure storage, on my html page, i will put the src of the image to serve from the CDN. But the users wouldn't be able to see it until 15 mins has past, and the 15 mins "time lag" is not documented thus i can't even try to do a batch job to update the url. Further more as mentioned by you, azure storage have limits on throughput etc. What's a better way to implement this rather common scenario? – Lee Gary Aug 07 '14 at 01:20