Andrew Connell Critical Path Training OFC401 Who Am I? Andrew Connell MVP Office SharePoint Server Developer, Instructor, Author and Speaker Co-founder, Critical Path Training http://www.criticalpathtraining.com Blog: MOSS WCM.

Download Report

Transcript Andrew Connell Critical Path Training OFC401 Who Am I? Andrew Connell MVP Office SharePoint Server Developer, Instructor, Author and Speaker Co-founder, Critical Path Training http://www.criticalpathtraining.com Blog: MOSS WCM.

Andrew Connell
Critical Path Training
OFC401
Who Am I?
Andrew Connell
MVP Office SharePoint Server
Developer, Instructor, Author and Speaker
Co-founder, Critical Path Training
http://www.criticalpathtraining.com
Blog: MOSS WCM & SharePoint Development Focus
http://www.andrewconnell.com/blog
Book: Pro SharePoint 2007 WCM Development
http://www.andrewconnell.com/go/131
Agenda
What’s this session all about?
Taxonomy / site topology
Customization status of files
Common custom code performance issues
Minimizing the page payload
Configuring and tuning Publishing site caching
IIS HTTP compression
Capacity considerations and querying
SharePoint lists
Web application configuration topics
Taxonomy / Site Topology
Group anonymous and secured resources in
different sections of the site
Caching more effective on similar resources
Minimize secured number of secured items
in pages
Each request causes two roundtrips:
1. Validates credentials
2. Role provider enumerates list of SharePoint groups user
belongs to validate access
Keep Files Uncustomized
Customized (unghosted) files are subject to the
safe mode parser
This adds an extra level of analysis to
each request
Publishing sites highly subject to this as many
custom ASPX files (page layouts) created by
developers and designers
Web Part Performance
Long running Web parts can kill the UX
One slow Web part can kill a page
How many Web parts are on the page?
At development time, no way to know
how many Web parts on the page…
Or more importantly, how many instances
of your Web part are on the page!
Recommendation: Leverage
async programming techniques
Tip: Create a worker class to handle async code
Properly Disposing Objects
SPSite and SPWeb are small managed
code wrappers to much larger unmanaged
code blocks
.NET Garbage Collector does not release these objects from
memory in a timely manner because of the larger
unmanaged portion
Tip: Don’t rely on the .NET Garbage Collector,
call Dispose() when finished using them
Under heavy loads, this can cause
High memory use and OutOfMemory() exceptions
Frequent WSS application pool recycles
Application crashes
Avoid Unnecessarily Creating/Disposing
of Objects
Most SharePoint collections expose indexes
Using indexes on each call
degrades performance
SharePoint has to hydrate an internal
copy of the object on each call
Results in numerous unnecessary
Creation/disposal of objects
Roundtrips to the SharePoint content database
Minimizing the Page Payload
Page payload = combined total size of all files required for a
page request
Includes all HTML markup, images, JavaScript, CSS…
SharePoint heavy page payloads primarily due to table-based
design and JavaScript
Recommendations:
Implement CSS-based design (aim for accessible sites) which can
dramatically reduce the markup
Tune IIS HTTP compression (more later…)
Lazy-load core.js - See MSKB # 933823
Or suppress it all together!
Clustering images together to reduce the requests
Publishing Portal Page Payload
Branding & Content
(91k)
29%
45%
core.js (54k)
26%
Other scripts & CSS
(59k)
Limiting The Page Payload
Page payload is the combined
file size of a single page request
OOTB, Publishing Portal homepage is 204k
Content + branding = 91k (44.6% of payload)
core.js accounts for 54k (26% of payload)
Can implement techniques to “lazy load”
core.js or even fully suppress it!
Configure IIS dynamic compression
Build accessible (CSS based) sites for
up to a ~50% reduction in payload
Examining The Publishing Portal Page
Payload and ActiveX
CAS Policies for Custom Code
SharePoint sites default to WSS_Minimal
When creating custom components, developers
are presented with two options:
Increase trust of Web app (WSS_Medium / Full)
Increase trust of specific components w/ CAS policy
Increasing the trust of the Web app is easier,
BUT custom CAS policy for a specific component
is much more secure
The “Lockdown Feature”
By default, all users in a SharePoint site can access the
SharePoint-y pages
http://litwareinc.com/pages/forms/allitems.aspx
Not desirable in publishing sites
Controlled by the “View Application Pages” right
granted by “Limited Access”
SPBasePermissions.ViewFormPages
Feature ViewFormPagesLockdown removes this right
from Limited Access
Automatically activated by Publishing Portal template
Note: need to reactivate when changing the
anonymous settings on a site collection
Page Output Cache
Fastest type of caching
After ASP.NET 2.0 page lifecycle generates the HTML
markup it is saved in RAM
Future requests bypass the ASP.NET 2.0 page lifecycle
and instead used cached HTML
Publishing sites provide Web interface to create
cache “profiles”
Profiles assigned to individual sites
Note: not enabled by default
Object Cache
Like output cache, provided by ASP.NET 2.0
Commonly used objects are stored in RAM
Master pages, page layouts, etc.
Cross-site queries (ie: CQWP queries) stored in RAM to
eliminate future roundtrips to the site collection’s
content database
Note: not enabled by default
Amount of memory configurable (100MB = default)
Tip: Use the ASP.NET 2.0 performance counter Cache
Hit Ratio to determine effectiveness:
Increase configured memory if not exceeding 90%
Disk-Based Cache
Commonly requested static files (images, CSS, JS, etc)
stored in libraries in the site are pulled from the
content database on each request
Disk-based cache stores these files on the WFE server’s
disk to eliminate future round trips
Can optionally configure the max-age HTTP header
causing user’s browsers to not request the files for a
specified duration
Configured via the Web app’s web.config
Static and Dynamic Compression
Used to minimize the page payload
When SharePoint installed, IIS is configured to compress static
and dynamic files
Static: HTM, HTML, TXT
Dynamic: ASP, EXE
Example: core.js is 257 KB on disk, but IIS compresses to 54 KB
before sent to client
IIS HTTP compression level is configurable
Requires lots of fine tuning and testing
Higher compression = higher CPU use and smaller files
Lower compression = lower CPU use and larger files
Tip: increase as high as the CPU can handle
IIS v6 vs. IIS v7 Compression
IIS v6 vs. IIS v7 Compression
IIS 6
IIS 7
Default Static Comp.
10
7
Default Dynamic Comp.
0
0
Compress by File Type
YES
NO
Compress by MIME Type
NO
YES
Compress content before adding to page output cache
NO
Configurable
In IIS 7, compression (static & dynamic) is on / off & is enabled / disabled
based on CPU utilization
In IIS 7, markup can be compressed before inserting into page
output cache
Not enabled by default
Windows 2003 / IIS 6 Compression
Configuration
Tip: Add .CSS & .JS to static file list:
CSCRIPT.EXE ADSUTIL.VBS SET
W3Svc/Filters/Compression/DEFLATE/HcFileExtensions “htm” “html” “txt”
“css” “js”
CSCRIPT.EXE ADSUTIL.VBS SET
W3Svc/Filters/Compression/GZIP/HcFileExtensions “htm” “html” “txt” “css”
“js”
Tip: Add .AXD & .ASPX to dynamic file list
CSCRIPT.EXE ADSUTIL.VBS SET
W3Svc/Filters/Compression/DEFLATE/HcScriptFileExtensions “asp” “exe”
“axd” “aspx”
CSCRIPT.EXE ADSUTIL.VBS SET
W3Svc/Filters/Compression/GZIP/HcScriptFileExtensions “asp” “exe” “axd”
“aspx”
Tip: Increase dynamic compression level to 9, then test
CSCRIPT.EXE ADSUTIL.VBS SET
W3Svc/Filters/Compression/DEFLATE/HcDynamicCompressionLevel “9”
CSCRIPT.EXE ADSUTIL.VBS SET
W3Svc/Filters/Compression/GZIP/HcDynamicCompressionLevel “9”
Note: higher compression level = higher CPU use
Tip: Don’t compress images (already compressed)
Windows 2008 / IIS 7 Compression
Configuration
Tip: Increase dynamic compression level to 9, then test
<httpCompression>
<scheme […] dynamicCompressionLevel=“9” />
</httpCompression>
Tip: Change dynamic compression CPU utilization threshold
range from 20-75%
APPCMD.EXE set config –section:httpCompression
/dynamicCompressionDisableCpuUsage:75
APPCMD.EXE set config –section:httpCompression
/dynamicCompressionEnableCpuUsage:20
Tip: Enable caching before insertion into page output cache
APPCMD.EXE set config –section:urlCompression
/dynamicCompressionBeforeCache:true
Examining Caching, IIS HTTP
Compression and Results
Capacity Considerations
Performance starts to degrade as the number
of items in a collection approaches 2,000 items
Not a hard limit, just a recommendation
Performance degradation primarily
limited to list views and upgrades
Mitigate the issue by grouping items
within containers
Group similar sites within one site
Group list items within folders
Options for Querying SP Data
List with 100,000 items, Page Size of 100 Items, no
Indexed Columns, Site Under Load
milliseconds
201622
145552
3585 392 339
327 327
40
Options for Querying SP Data
List with 100,000 items, Page Size of 100 Items, no
Indexed Columns, Site Under Load
milliseconds
3585
392
339
327
327
40
Options for Querying SP Data
Multiple ways to get data out of SharePoint
Enumerate over a list using for/each
Collection of SPListItems via SPQuery
DataTable via GetDataTable() and SPQuery
PortalSiteMapProvider, Search, Lists.asmx
Slowest: Enumerating over lists and DataTable
Fastest: SPQuery and PortalSiteMapProvider
See: Working with Large Lists in MOSS 2007
http://www.andrewconnell.com/go/160
Web Application Configuration
For Internet-facing sites, it is recommended to disable
the following:
User Presence Information
Central Admin » App Mgmt » Web App General Settings
Blog API
Central Admin » App Mgmt » Web App General Settings
Incoming Email
Central Admin » Operations » Incoming E-Mail Settings
Disk-Based Caching
Enable disk-based caching and set the max-age attribute for
local user browser caching
Summary
What did we learn?
Taxonomy / site topology
Customization status of files
Common custom code performance issues
Minimizing the page payload
Configuring and tuning publishing site caching
IIS HTTP compression
Capacity considerations and querying
SharePoint lists
Web application configuration topics
Additional Resources
MSDN: How to Optimize a SharePoint Server 2007
Web Content Management Site for Performance
http://www.andrewconnell.com/go/161
MSDN: Additional Performance and Capacity Planning
Factors
http://www.andrewconnell.com/go/162
MSKB # 933823: Delay loading of core.js
http://www.andrewconnell.com/go/163
TechNet: Optimizing MOSS for WAN Environments
http://www.andrewconnell.com/go/165
Resources
www.microsoft.com/teched
www.microsoft.com/learning
Sessions On-Demand & Community
Microsoft Certification & Training Resources
http://microsoft.com/technet
http://microsoft.com/msdn
Resources for IT Professionals
Resources for Developers
www.microsoft.com/learning
Microsoft Certification and Training Resources
Track Resources
Spin the Wheel: Attend SharePoint breakout sessions Mon-Thurs and collect
the picture of the day. Come by the booth for a chance to spin the SharePoint
wheel. Collect all 4 pictures and enter to win a Microsoft Arc Mouse, drawing
11:30am on Friday, game cards at the booth.
Product Info http://www.microsoft.com/SharePoint
SharePoint Conference 2009 www.mssharepointconference.com
Dev Resources
SharePoint MSDN Web Site:
http://msdn.microsoft.com/sharepoint
SharePoint Developer Resources: http://mssharepointdeveloper.com/
ITPro Resources
SharePoint Tech Center: http://technet.microsoft.com/en-us/office/sharepointserver/
SharePoint Best Practices: http://technet.microsoft.com/enus/office/sharepointserver/bb736746.aspx
Complete an
evaluation on
CommNet and
enter to win!
© 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.
The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should
not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS,
IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.