Pregunta

How does Sitecore deal with race conditions when publishing media items?

Scenario:

  1. A non versioned media item with a 500mb mpg file (stored as blob) is being downloaded by a site visitor.
  2. The download will take at best a bew minutes, at worst could be measured in hours (if they're on a low bandwidth connection).
  3. While the user is downloading an author uploads a new version of the mpg on the media item and publishes.

What happens, and why?

Other variations include: The security settings on the media item change to block access from the visitor downloading The media item is deleted and the change published

I'm guessing that in all these cases the download is aborted, but if so, what response does the server send?

¿Fue útil?

Solución

This is not a difinitive answer, and I agree w/Stephen about dedicated streaming partner. I wonder how such systems handle this.

It seems that Sitecore creates a new media cache file for each published and accessed revision, so the HTTP transmit can continue reading the old file while the system writes the new file. Not sure if/how that works if you disable caching (I didn't try disabling caching). Otherwise, trying to write while reading could be blocked or interfere with read.

Note that you get a new revision ID even if you don't version. And it might be the publication that causes a new cache entry, not the occurrence of a new revision.

Otros consejos

I don't have an exact answer, but Sitecore caches blob assets on the file system under /App_Data/MediaCache/ so perhaps the existing asset is still in that cache. I'm not sure how Sitecore's media caching mechanism works but I bet it purges/re-caches on the next request to the new assets once the asset is completely there.

Just a guess. Maybe decompile the kernel to find the code that handles caching media.

(Not really an answer.. just comment was too big for the box :P)

This is a very interesting question.. Sitecore's media performance is done a lot through it caching a copy to disk and the delivering it from there on subsequent requests (also for caching scaled copies of originals such as thumbnails etc). The file is flushed once the original item is edited in some way and then re-published.

I am uncertain (and intrigued) how this would affect a large file as I think a lot of people assume media is probably smaller files such as images or pdfs etc that a user would just re-request if broken and how this effects a file currently being streamed when the item itself was updated. I'm sure a lot of the work at that point is IIS/ASP.NET streaming rather than Sitecore itself.

I'm not sure if Sitecore's cache would protect / shield against that but this should be pretty simple enough to test with a larger media file. Interested in the results (as larger files I've delivered personally have been done by CDN or a dedicated streaming partner)

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top