Your SlideShare is downloading. ×
0
#SPSBEBoosting Performance on    Publishing sites            #SPSBE14        Karine Bosch         SharePoint MVP
A big thanks to our sponsorsPlatinum SponsorsGold Premium Sponsors            Venue SponsorGold Sponsors
About me• SharePoint MVP since 2008• Technical assistent of Patrick Tisseghem till September 2008• Developer of the U2U CA...
Agenda• Introduction• Caching data• Techniques to reduce the page load• Tools to measure performance
Introduction• Data is stored in SQL Server database• User requests require data                                           ...
Types of Caching• Caching data   • BLOB Cache       => caches files stored in the content database   • IIS Cache        =>...
BLOB Cache• BLOB = Binary Large Object• BLOB cache is configured on Web Application level in  web.config• BLOB cache store...
BLOB Cache• BLOB Cache is highly optimized to serve anonymous requests     • Images and SiteCollectionImages library have ...
BLOB Cache• BLOB Caching is useful when   • Resources are frequently accessed   • Rich media is used (videos, etc)• BLOB C...
Configuring BLOB Cache• BLOB Cache is configured in web.config of WFE   • Local directory on WFE   • Files with specific e...
Demo  BLOB Cache
IIS Cache• Files stored in _layouts/images folder of WFE• Files are cached on  local browser cache• Default invalidation  ...
Demo  IIS Caching
Output Cache• SharePoint Server uses ASP.NET output cache   • In-memory cache that stores rendered ASPX pages per ASP.NET ...
Output Cache Profiles• Configuration of Cache profiles   • Specify the different variants of a page that can be stored in ...
Configuring Output Cache• Following features must be enabled:    • Publishing Infrastructure site collection feature    • ...
Configuring Cache Profiles• Cache Profiles specify the different variants of a page that can  be stored in cache• Site col...
Demo  Output Cache
Object Cache• Stores data objects in-memory on WFEs• Publishing features must be activated• Some SharePoint artifacts use ...
Object Cache• Data is cached based on user rights   • PortalSuperUserAccount   • PortalSuperReaderAccount• Cache invalidat...
Configuring Object Cache• Set up Portal Super Accounts        $wa = Get-SPWebApplication -Identity "<WebApplication>"     ...
HttpRuntime.Cache Code Sample•   ASP.NET cache class             string cacheKey = "BeersOfTheWeek";                      ...
Demo  Object Caching
Tools• Tools to measure performance and page load   • Firebug   • Yslow   • Developer Dashboard   • SPMonitoredScope
Developer Dashboard• Disabled by default• Can be enabled via   • Object Model   • Stsadm   • PowerShell• Display levels   ...
SPMonitoredScope• Included for web parts• Not included for custom controls       using (SPMonitoredScope breweryBannerScop...
Demo Developer Dashboard and SPMonitoredScope
Reduce the Page Load• Suppress JavaScript files and CSS files that are not used in  anonymous mode• Minimize JavaScript fi...
Conclusion• Improve performance using caching mechanisms:   • BLOB cache       =>    files in document libraries   • IIS c...
We need your feedback!                Scan this QR code or visit                http://svy.mk/sps2012be                Our...
Upcoming SlideShare
Loading in...5
×

Karine bosch caching-spsbe14

619

Published on

You can build very attractive sites but if your pages don't render within the second, you will be out of visitors in no time. Highly performing SharePoint sites can be a true challenge.
In this session I will explain how the different caching mechanism can highly improve the performance of your SharePoint Publishing site.

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
619
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
11
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • A SharePoint Server installation consists of an instance of Microsoft® SQL Server® and at least one front-end web server. When users request data (for example, a page or document) from SharePoint Server, the SharePoint application, running on the front-end web server, retrieves all the relevant data from SQL Server to handle the user request. Although this ensures that all users always see the most up-to-date data, it has the downside of requiring constant data traffic between SQL Server and the front-end web server.
  • Extra roundtrips are to fetch permission and other metadata so the cache can serve the file securely. Also, to avoid serving stale content, the BLOB cache will toss out files if there is any chance that the cached copy might be out of date. After a file has been removed from the cache, the first hit penalty applies again to re-cache the file.In addition to reducing SQL Server round trips, the BLOB cache also helps reduce the time it takes to reload web pages by adding cache control headers to the HTTP responses for the files it serves. These headers tell the user’s browser to save these files in the browser’s cache. When the browser needs one of the cached files, it can use its cache instead of making requests to SharePoint Server. This results in fewer HTTP requests and a significantly reduced page load time.If there is content in the site that doesn’t have to be secured it would be beneficial to enable anonymous access to those files to take advantage of the BLOB cache’s optimizations for anonymous authentication.How BLOB cache can be configured with extended web app: pg 6
  • Extra roundtrips are to fetch permission and other metadata so the cache can serve the file securely. Also, to avoid serving stale content, the BLOB cache will toss out files if there is any chance that the cached copy might be out of date. After a file has been removed from the cache, the first hit penalty applies again to re-cache the file.In addition to reducing SQL Server round trips, the BLOB cache also helps reduce the time it takes to reload web pages by adding cache control headers to the HTTP responses for the files it serves. These headers tell the user’s browser to save these files in the browser’s cache. When the browser needs one of the cached files, it can use its cache instead of making requests to SharePoint Server. This results in fewer HTTP requests and a significantly reduced page load time.If there is content in the site that doesn’t have to be secured it would be beneficial to enable anonymous access to those files to take advantage of the BLOB cache’s optimizations for anonymous authentication.How BLOB cache can be configured with extended web app: pg 6
  • Example:The BLOB cache handles multiple requests for the same file by sharing the cached copy with all the requests. It can even do this before the file has been completely read from SQL Server. For example, a 500 MB video of a keynote presentation is posted on SharePoint Server and then a link to this video is sent out via email. There can be many users accessing the file at the same time. SharePoint Server (without the BLOB cache) would fetch the video from SQL Server once for every user requesting it. That would have huge performance implications for anyone else using the site. With the BLOB cache, even if the video isn’t yet fully cached, the video would be retrieved only once (per front-end web server) from SQL Server to handle all the requests. This optimization makes the BLOB cache indispensible for serving large files from SharePoint Server.
  • Configuring the application poolWhen you enable the BLOB cache, increase the startup and shutdown time limits for the application pool. The recommended setting is at least 300 seconds. This will allow the BLOB cache enough time to initialize or serialize its index on startup or shutdown. Setting this value to 300 seconds does not cause it to take 300 seconds to start or stop, but it does prevent IIS from terminating the application pool until 300 seconds have elapsed. Increasing this limit, especially the shutdown limit, prevents the application from being terminated – possibly when the cache is serializing its index. If the index isn’t completely serialized it is considered corrupted and the cache is flushed on the next startup.Maintaining the BLOB cache: pg 19
  • QUESTION: why store images in content database and not all in _layoutsfolder? ANSWER: updatable by users/content editors. Otherwisedeployment of Administratorrequested.
  • This cache can help increase page throughput and reduce CPU load on the front-end web server and the instance of SQL Server because pages won’t have to be re-rendered on each request. If a site is configured for anonymous access, the front-end web servers won’t even have to request data from SQL Server to do a permission check for cached requests. In SharePoint Server only Publishing pages can be cached in the output cache. When a Publishing page is rendered, the Publishing feature assembles the page dynamically. To do this, Publishing must first fetch the page layout and then fetch the contents of the page. Both of these operations incur SQL Server round trips that affect throughput and latency. To increase throughput and scalability, Publishing pages can use the output cache so that pages aren’t rendered on each request.Publishing is a feature in SharePoint Server that allows the separation of content and its presentation. In this model a page layout is created that defines the place holders for content; pages are the containers for the content. The target scenario for this feature is an Internet facing web site that has multiple content contributors where all of the content shares a common page structure.Cache ProfilesThe cache profile is a collection of settings and parameters that are used to determine if and how a page will be cached. For example, a profile might require that pages are not cached when the requestor is someone that can edit the page so that the user can see the latest version. Another profile might specify that different copies of the pages should be generated depending on what browser is making the request. Along with those settings, the cache profile also specifies how pages in the cache are invalidated. When a page is invalidated, the next request for that page is re-rendered. This new rendered copy replaces the invalidated copy in the cache.+ pg 11Vary Bypg 11
  • This cache can help increase page throughput and reduce CPU load on the front-end web server and the instance of SQL Server because pages won’t have to be re-rendered on each request. If a site is configured for anonymous access, the front-end web servers won’t even have to request data from SQL Server to do a permission check for cached requests. In SharePoint Server only Publishing pages can be cached in the output cache. When a Publishing page is rendered, the Publishing feature assembles the page dynamically. To do this, Publishing must first fetch the page layout and then fetch the contents of the page. Both of these operations incur SQL Server round trips that affect throughput and latency. To increase throughput and scalability, Publishing pages can use the output cache so that pages aren’t rendered on each request.Publishing is a feature in SharePoint Server that allows the separation of content and its presentation. In this model a page layout is created that defines the place holders for content; pages are the containers for the content. The target scenario for this feature is an Internet facing web site that has multiple content contributors where all of the content shares a common page structure.Cache ProfilesThe cache profile is a collection of settings and parameters that are used to determine if and how a page will be cached. For example, a profile might require that pages are not cached when the requestor is someone that can edit the page so that the user can see the latest version. Another profile might specify that different copies of the pages should be generated depending on what browser is making the request. Along with those settings, the cache profile also specifies how pages in the cache are invalidated. When a page is invalidated, the next request for that page is re-rendered. This new rendered copy replaces the invalidated copy in the cache.+ pg 11Vary Bypg 11
  • QUESTION: why store images in content database and not all in _layoutsfolder? ANSWER: updatable by users/content editors. Otherwisedeployment of Administratorrequested.
  • More detailspg 22, 23
  • Examples: properties of SPWeb or SPList, custom objects.Remark: don’t store SPWebobject in object cache!The PortalSiteMapProvider is a public API that can be used to execute a query, and the results that are returned will be cached. For example, an image rotator could be written that would query a list to get the URLs of 10 images.
  • When a control asks the object cache to make a query to get data, the cache will not make the query as the user making the request but instead will make the query twice: once as a user called the PortalSuperUserAccount (referred to as Super User) and once as PortalSuperReaderAccount (referred to as Super Reader). The results for the Super User query will include draft items and the results for the Super Reader query will include only published items. The cache detects duplicates and single instances the results set. The cache will then check the ACLs for the user that initiated the request and will return the appropriate results to that user. Because of the Portal Super Account users, the cache only has to store results for two users which will increase hit count and decrease the cache’s memory footprint.Out of the box, the Super User account is the web application’s System Account and the Super Reader account is NT Authority\\Local Service. Farm administrators are advised to change the default accounts for the following reasons. Some items get checked out to System Account (In Place Records is a feature that does this). When a query is made that includes these items, the checked-out version of the items is returned instead of the latest published version. That is usually not what is expected to be returned and the cache has to make a second query to fetch the versions of the file that is not checked out. This extra SQL Server round trip results in a performance hit for every query that includes these checked out items. The same would be true for any user account if that account were used for the Super User account and the user had items checked out. The user configured to be the Super User or Super Reader should not be an account that is used to log into the site or run programs that use the SharePoint API to make changes to a site. This is a precaution that will ensure the Portal accounts aren’t inadvertently used to check items out. Also, don’t use the application pool account or any account that has “Runs as System” checked in the user policy on the web application because these accounts will have the same undesirable behavior as the default account. Finally, the cache needs to have results from users who can and cannot see drafts so the Super User and Super Reader accounts must not be the set to the same account. The cache will not perform correctly if the Super User and Super Reader accounts are set to the same account.SharePoint always returns the checked-out version for items that a user has checked out.Cache invalidation: pg 15
  • Intro: The object cache cannotbedisabled and thereislittlethatcanbeconfigured. None of the out of box settings should have to be changed, but there are two user accounts that should be set up to ensure the best performance. Configure Portal Super Accounts: pg 25Tuning options: pg 26Configure object cache max size: pg 27
  • In web.configIn code:portalSiteMapProvider = siteMapProvider as PortalSiteMapProvider; portalSiteMapProvider.DynamicChildLimit = 0; portalSiteMapProvider.EncodeOutput = true; portalSiteMapProvider.IncludePages = PortalSiteMapProvider.IncludeOption.Always; portalSiteMapProvider.IncludeSubSites = PortalSiteMapProvider.IncludeOption.Never;
  • Transcript of "Karine bosch caching-spsbe14"

    1. 1. #SPSBEBoosting Performance on Publishing sites #SPSBE14 Karine Bosch SharePoint MVP
    2. 2. A big thanks to our sponsorsPlatinum SponsorsGold Premium Sponsors Venue SponsorGold Sponsors
    3. 3. About me• SharePoint MVP since 2008• Technical assistent of Patrick Tisseghem till September 2008• Developer of the U2U CAML Builder• Technical Lead SharePoint Competence Center @ ING• Blog: http://karinebosch.wordpress.com• Twitter: kbosie
    4. 4. Agenda• Introduction• Caching data• Techniques to reduce the page load• Tools to measure performance
    5. 5. Introduction• Data is stored in SQL Server database• User requests require data No Caching 2. SQL Get Data 1. HTTP GET 3. Data Returned 4. HTTP Response• No caching limits scalability• SharePoint caches run on the WFE(s)• Caches maintain copies of data locally on WFE• User requests are served from cache on WFE
    6. 6. Types of Caching• Caching data • BLOB Cache => caches files stored in the content database • IIS Cache => caches files stored in the _layouts folder • Output Cache => caches .aspx pages • Object Cache => caches data objects• Require addintional system resources
    7. 7. BLOB Cache• BLOB = Binary Large Object• BLOB cache is configured on Web Application level in web.config• BLOB cache stores files from content database on a local directory of each WFE • Images, CSS files, JavaScript files• Second request serves file from disk• Tradeoff: • Extra roundtrips to SQL Server to fetch file• Cache Invalidation
    8. 8. BLOB Cache• BLOB Cache is highly optimized to serve anonymous requests • Images and SiteCollectionImages library have AllowEveryoneViewItems property set to True. • No SQL Server roundtrip to check user ACLs• Adds cache control headers to HTTP Responses to save file in user’s browser cache
    9. 9. BLOB Cache• BLOB Caching is useful when • Resources are frequently accessed • Rich media is used (videos, etc)• BLOB Caching is less useful when • Resources are not frequently accessed • Files are modified frequently
    10. 10. Configuring BLOB Cache• BLOB Cache is configured in web.config of WFE • Local directory on WFE • Files with specific extensions • List of extensions can be configured • Size limit <BlobCache location="C:blobCache" path=".(gif|jpg|png|css|js)$" maxSize="10" max-age="86400" enabled="true"/>
    11. 11. Demo BLOB Cache
    12. 12. IIS Cache• Files stored in _layouts/images folder of WFE• Files are cached on local browser cache• Default invalidation period: 365 days
    13. 13. Demo IIS Caching
    14. 14. Output Cache• SharePoint Server uses ASP.NET output cache • In-memory cache that stores rendered ASPX pages per ASP.NET application • Reduces CPU load and SQL Server roundtrips• In SharePoint Server only Publishing pages can be cached • Publishing Feature fetches page layout and then content of the page• Configured per site collection• Output Cache is highly optimized for anonymous access• Memory requirements: • (2 x page size) + 32 KB of memory per rendered copy of a page
    15. 15. Output Cache Profiles• Configuration of Cache profiles • Specify the different variants of a page that can be stored in cache • Vary By• Default cache profiles • Organaized by • user access rights • Browser type
    16. 16. Configuring Output Cache• Following features must be enabled: • Publishing Infrastructure site collection feature • Publishing site feature• Site collection settings > Site collection output cache • Enable output cache check box
    17. 17. Configuring Cache Profiles• Cache Profiles specify the different variants of a page that can be stored in cache• Site collection settings > Site collection cache profiles• Fields that can be configured • Enabled • Duration • Check for Changes • Vary By Parameter • Perform ACL check • …
    18. 18. Demo Output Cache
    19. 19. Object Cache• Stores data objects in-memory on WFEs• Publishing features must be activated• Some SharePoint artifacts use object cache mechanism by design: • Cross-list Query Cache • Content By Query Web Part • PortalSiteMapProvider API • Search Query Box • Metadata navigation• HttpRuntime.Cache
    20. 20. Object Cache• Data is cached based on user rights • PortalSuperUserAccount • PortalSuperReaderAccount• Cache invalidation• Size: allocate 500KB RAM per site collection
    21. 21. Configuring Object Cache• Set up Portal Super Accounts $wa = Get-SPWebApplication -Identity "<WebApplication>" $wa.Properties["portalsuperuseraccount"] = "<SuperUser>" $wa.Properties["portalsuperreaderaccount"] = "<SuperReader>" $wa.Update()• Site collection settings > Site collection object cache• Tuning options • Max size • Flushing • Cache Invalidation
    22. 22. HttpRuntime.Cache Code Sample• ASP.NET cache class string cacheKey = "BeersOfTheWeek"; List<Beer> beerList = null;• Cache key // check the cache object o = HttpRuntime.Cache.Get(cacheKey);• Lock before retrieving data from database if (o == null) { object lockHandle = new object();• Insert object(s) in cache for lock (lockHandle) { a certain period of time // check again if cache is not filled again o = HttpRuntime.Cache.Get(cacheKey); if (o == null) { beerList = RetrieveWithQuery(); if (beerList != null) { // add the list to the cache HttpRuntime.Cache.Insert(cacheKey, beerList, null, DateTime.Now.AddMinutes(15.0), TimeSpan.Zero); } } else beerList = (List<Beer>)o; } } else beerList = (List<Beer>)o;
    23. 23. Demo Object Caching
    24. 24. Tools• Tools to measure performance and page load • Firebug • Yslow • Developer Dashboard • SPMonitoredScope
    25. 25. Developer Dashboard• Disabled by default• Can be enabled via • Object Model • Stsadm • PowerShell• Display levels • On • Off • On Demand
    26. 26. SPMonitoredScope• Included for web parts• Not included for custom controls using (SPMonitoredScope breweryBannerScope = new SPMonitoredScope(“Brewery Banner control”) { // your code goes here }
    27. 27. Demo Developer Dashboard and SPMonitoredScope
    28. 28. Reduce the Page Load• Suppress JavaScript files and CSS files that are not used in anonymous mode• Minimize JavaScript files• Sprites • Images • CSS
    29. 29. Conclusion• Improve performance using caching mechanisms: • BLOB cache => files in document libraries • IIS cache => files in _layouts folder • Output cache => publishing pages • Object cache => data objects• Caching takes place on: • Web front ends • Client browser
    30. 30. We need your feedback! Scan this QR code or visit http://svy.mk/sps2012be Our sponsors:
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×