Monday, October 17, 2011

Sitecore Media Library Performance Optimization Checklist


Here is a quick checklist that you can use in order to get more performance out of your Sitecore Media Library’s delivery.

media_library
1. Ensure data/item/prefetch caches are of a sufficient size.
2. Ensure client caching is properly configured (MediaResponse.XXX settings).
3. Media Library structure – make sure the tree is balanced.
4. Change MediaLinkPrefix from ~/media to something else, for example "-/media":
- set the value of the “Media.MediaLinkPrefix” to alternative prefix:
<setting name="Media.MediaLinkPrefix" value="-/media" /> 
-add the following line to the customHandlers section, don’t remove the existing one mapped to “~/media”:
<customHandlers> 
   <handler trigger="-/media/" handler="sitecore_media.ashx" /> 
   <handler trigger="~/media/" handler="sitecore_media.ashx" /></customHandlers>
This really helps for high traffic websites. Apparently tilde in the path forces different way of resolving the system permissions on a resource on Windows Server.
5. Consider IIS kernel and/or output caching, but keep in mind this consideration.
6. Consider adding other edge caching options in front of the web servers.
7. Leverage CDN like AKAMAI.
Some links and food for thought:
8. Use dedicated “Sitecore media server” (e.g. replace hostname in media links to point to another Sitecore instance; would require some customization).
Some great stuff here:

Thanks to the guys from our brilliant customer service for helping me to come up with a more complete list.

Updated 2/8/2012. Confusing typo fixed.


10 comments:

Per Manniche Bering said...

Any documentation to backup your point in 4.?

Alex Shyba said...

Hi Per,

Wait...you don't trust me after all these years? :-)))

But seriously, nothing official at this point (hence a blog post), but our numerous load testing exercises with the customers show that this little change has dramatic difference on performance. Ability to change this prefix came in after we discovered this.

But you bring up a good point, you need to see the numbers. Hope I can get to it at some point.

-alex

Per Manniche Bering said...

hehe, well I like numbers behind a statment like that - Especially when the setting is the default one :) But good find anyways!

Per Manniche Bering said...

Ok, did a test of this in point 4 and with 10.000 HTTP GETs to some image in the media library I saw a performance improvement of x 8! And your right, it's only on Win2k8 you see this kind of improvement, on Win7 it's only x 0.5. May I suggest that Sitecore change ~ to - as the default, and also for all other handlers like the icon handler etc. :)

Alex Shyba said...

Wow! 8x that's no joke.
I will communicate this through appropriate channels. Thanks for taking an effort int testing!

-alex

Per Manniche Bering said...

My test was not showing the correct improvements, a new run showed 0.5 better on Win2k8 and 0.2 on Win7. Still good for a small change like that :)

sumith said...

On point 3, what would be recommend as a balanced tree, number of items or structured folders/items

Alex Shyba said...

Sumith,

Not more than 100 items per level is a common recommendation.

-alex

Arthur said...

Hey Alex--one important point about step 4. If you've already added items to the media library using the tilde (~), then change to something like a hyphen (-), we found admin users were no longer able to access existing media items via the content editor--they were getting "unauthorized access" errors. So we've changed back to the tilde, and access has been restored. Weird.

Thanks,

Arthur

Alex Shyba said...

Looks like your image fields have hardcoded ~/media in the raw values. that's most likely what messes things up.
We fixed this in one of the later versions.
You can probably fun a cleanup script on your content tree and fix this up. email me if you need the details.