R – Are SharePoint site templates really less efficient than site definitions

performancesharepointsite-definitionsitetemplate

So, it seems in the SharePoint blogosphere that everybody just copies and pastes the same bullet points from other blogs. One bullet point I've seen is that SharePoint site templates are less efficient than site definitions because site definitions are stored on the file system. Is that true?

It seems odd that site templates would be less efficient. It's my understanding that all site content lives in a database, whether you use a site template or a site definition. A site template is applied once to the database, and from then on the site should not care if the content was created using a site template or not.

So, what is an architectural reason why a site template would be less efficient than a site definition?


Edit: Links to the blogs that say there is a performance difference:

  • From MSDN: Because it is slow to store templates in and retrieve them from the database, site templates can result in slower performance.
  • From DevX: However, user templates in SharePoint can lead to performance problems and may not be the best approach if you're trying to create a set of reusable templates for an entire organization.
  • From IT Footprint: Because it is slow to store templates in and retrieve them from the database, site templates can result in slower performance. Templates in the database are compiled and executed every time a page is rendered.
  • From Branding SharePoint:Custom site definitions hold the following advantages over custom templates:
    • Data is stored directly on the Web servers, so performance is typically better.

At a minimum, I think the above articles are incomplete, and I think several are misleading based on what I know of SharePoint's architecture.

I read another blog post that argued against the performance differences, but I can't find the link.

Best Answer

The performance impact of using Site Templates versus Site Definitions is generally overstated.

Why?

Well, lets take this example:

  1. You take a Team Site site definition.
  2. You save it as a new Site Template
  3. You then create a new sub web based on this new site template.

What have you got? Well, the important thing to remember is that "Ghosting" happens at the PAGE level, NOT at the SITE level. Since you have not customised ANY pages, then any pages you access are still coming directly from the Site Definition, directly from the filesystem.

Want to prove it, here are two tests:

First Test

  1. Try modifying the default.aspx page in the original Site Definition.
  2. Check your site template, notice you see the modification.
  3. Its still "Ghosted" to the filesystem

Second Test

  1. Create a new site definition.
  2. Create a new site based on this new Site Definition.
  3. Create a new Site Template
  4. Send the site template to a mate with SharePoint and ask them to create a new subweb based on it.

It will fail. Why? Because the Site Definition does not exist on their machine.

So, to get back to your question, "Are SharePoint site templates really less performant than site definitions?" my answer would be: "Performance considerations should not play a role in your decision to use a Site Definition or a Site Template, the functional objective you have should be". Now it get controversial, but for me, there are very very few reasons to opt for a Site Definition over creating Features.

As far as "Ghosting" goes. Yup, when customised your page will be stored in the Database, and yup, you will have to do a database round trip to get it. But, SharePoint, smart that it is, will of course cache this. So, in theory, yup its slower, in practice, no one really notices.

Ghosting has been in the product since 2003 (probably in STS before that, dont remember) and I have never seen official guidance on the performance impact it has, nor anyone speculating beyond the "it is slower" comments.

This leads me to believe that it just isn't really worrying about. The bigger worry with "Ghosted" pages is the difficulty that comes with maintaining them, but then, with 2007 and Masterpages this is a much smaller problem.