20
dynaTrace 803: INTO THE WILD THE CHALLENGES OF CUSTOMIZED SHAREPOINT APPS IN RELEASE SPTechCon 2009-06-24, dynaTrace software Inc Andreas Grabner, [email protected] Technology Strategist

SharePoint TechCon 2009 - 803

Embed Size (px)

Citation preview

Page 1: SharePoint TechCon 2009 - 803

dynaTrace

803: INTO THE WILDTHE CHALLENGES OF CUSTOMIZED SHAREPOINT APPS IN RELEASE

SPTechCon2009-06-24, dynaTrace software IncAndreas Grabner, [email protected] Strategist

Page 2: SharePoint TechCon 2009 - 803

2dynaTrace

About me

• Andreas Grabner

• Technology Strategist

• dynaTrace Software (http://www.dynaTrace.com)

• Blog: http://blog.dynaTrace.com

• Why Performance is such a big topic for me?

Page 3: SharePoint TechCon 2009 - 803

3dynaTrace

Agenda

• This class will examine the real-world challenges of customized SharePoint applications when they are released “into the wild.” We will consider why such applications almost always work on the developer's machine—and why they often fail in production. Web parts and lists are the main focus in this advanced class

• LOTS OF DEMOS!!

Page 4: SharePoint TechCon 2009 - 803

4dynaTrace

Why do we end up with performance problems?

• TOO MUCH data is requested

• Data is REQUESTED in an INEFFICIENT way

• INEFFICIENT use of RESOURCES

• INEFFICIENT data RENDERING

• NEVER TESTED with REAL WORLD data

• NEVER TESTED UNDER LOAD

Page 5: SharePoint TechCon 2009 - 803

5dynaTrace

TOO MUCH data is requested

• SharePoint Lists

• Only display the data that the user really needs to see

• Limit the number of rows that are displayed in the ListWebPart

• Use Views to limit the number of columns that are displayed

• Use alternative WebParts

• Sometimes the ListWebView is not the right way to go

• Check the size of returned html page

• Consider the overhead on the network/browser rendering time

• SharePoint Indices

• Speed up access to large lists

• Require additional resources on database

• Only first index column is used in a View‘s Filter setting

Page 6: SharePoint TechCon 2009 - 803

6dynaTrace

TOO MUCH data is requested

• Optimize Lists based on Usage

• Analyze Usage of Lists & Views and optimize on slowest performing

Analyze usage and performance of all lists in SharePoint Analyze usage and performance of all views in SharePoint

Page 7: SharePoint TechCon 2009 - 803

7dynaTrace

TOO MUCH data is requested

• Custom Web Parts• Accessing Data via SharePoint Object Model

• Understand what is going on when accessing Data via API

• Use SPQuery‘s to access only the data you need to display

• Cache Data• Think about caching data that doesn‘t change frequently

Analyze where WebParts spend their time and how they access the data Analyze where most of the time is spent

Page 8: SharePoint TechCon 2009 - 803

8dynaTrace

TOO MUCH data is requested

• Recommendations from SharePoint Product Team• Monitoring

• Processor: % Processor Time: _Total. On the computer running SQL Server, this counter should be kept between 50%-75%.

• System: Processor Queue Length: (N/A). Monitor this counter to ensure that it remains below two times the number of Core CPUs.

• Memory: Available Mbytes: (N/A). Monitor this counter to ensure that you maintain a level of at least 20% of the total physical RAM free.

• Memory: Pages/sec: (N/A). Monitor this counter to ensure that it remains below 100

• ...

• SQL Server practices• Proactively check the integrity of your databases by running DBCC CHECKDB (‘<DB Name>’) on a

routine basis

• Monitor SQL Server index fragmentation

• Do not perform unsupported operations on the server running SQL Server

• Reference• Search for „Planning and Monitoring SQL Server Storage for Micr osoft SharePoint

Products and Technologies: Performance Recommendati ons and Best Practices “

Page 9: SharePoint TechCon 2009 - 803

9dynaTrace

TOO MUCH data is requested

DEMO• How to analyze current list usage behavior?

• How to analyze WebPart data access?

• Comparing Performance Impact when changing Views

• How indexed columns really work

Page 10: SharePoint TechCon 2009 - 803

10dynaTrace

Data is REQUESTED in an INEFFICIENT way

• SharePoint Object Model

• DO NOT iterate through all items in the list

• DO NOT access the Items property multiple times

• AVOID using the Count property

• Use CAML Queries and SPQuery‘s to select certain data

• Use the RowLimit and ListItemCollectionPosition Feature of SPQuery

DO NOT

String productName = productList.Items.GetItemById(“1234“)[“ProductName“].ToString();

DO

String productName = productList. GetItemById(“1234“)[“ProductName“].ToString();

or DO

SPQuery query = new SPQuery();

query.Query = "<Where><Eq><FieldRef Name='ID'/><Value Type='Text'>1234</Value></Eq></Where>";

String productName = productList.GetItems(query)[0][“ProductName“].ToString();

DO BEST

query.ViewFields = “<FieldRef Name=‘ProductName‘/>“;

Example: Query the Product Name of a certain Product identified by the Product ID

Page 11: SharePoint TechCon 2009 - 803

11dynaTrace

Data is REQUESTED in an INEFFICIENT way

• Whats going on „under the hood“ when using the SharePoint Object Model?

• How to improve SharePoint Data Access?

DEMO

Page 12: SharePoint TechCon 2009 - 803

12dynaTrace

INEFFICIENT use of RESOURCES

• SharePoint Object Model• SPSite and SPWeb hold references to native COM objects

• Release SPSite & SPWeb in order to free native resources

• Querying too much data results in high memory usage

• Reference• SPDisposeCheck tool

http://blogs.msdn.com/sharepoint/archive/2008/11/12/announcing-spdisposecheck-tool-for-sharepoint-developers.aspx

• http://msdn.microsoft.com/en-us/library/bb687949.aspx

• http://msdn2.microsoft.com/en-us/library/aa973248.aspx#sharepointobjmodel_otherobjectsthatrequire-disposal

Page 13: SharePoint TechCon 2009 - 803

13dynaTrace

INEFFICIENT use of RESOURCES

• Monitor resources

• Monitor Memory

• Monitor Database connections

• Monitor „critical“ SharePoint objects (SPSite, SPWeb)

• Identify leaking responsible WebParts

Monitor SharePoint Memory -> Growing Heap?Identify „leaking“ object instances

Identify who allocates those objects

Page 14: SharePoint TechCon 2009 - 803

14dynaTrace

Data is REQUESTED in an INEFFICIENT way

• How to identify a SPSite/SPWeb Resource Leak?

• How to identify resource intensive WebParts?

• How to monitor SharePoint Memory Issues down to the Object Model‘s Data Access classes?

DEMO

Page 15: SharePoint TechCon 2009 - 803

15dynaTrace

INEFFICIENT data RENDERING

• How to render data• StringBuilder vs. String concatenations

• Use HtmlTextWriter for custom WebParts

• How to access data• Follow the rules discussed earlier

• ViewState• Monitor ViewState Usage

• http://www.sitepoint.com/article/aspnet-performance-tips/2/

• Size matters• Minimize generated HTML

• Use style sheets instead of inline style definitions

• Enable content compression in IIS• http://planetmoss.blogspot.com/2007/06/dont-forget-iis-compression-colleague.html

• http://www.sitepoint.com/article/aspnet-performance-tips/3/

Page 16: SharePoint TechCon 2009 - 803

16dynaTrace

INEFFICIENT data RENDERING

• Steps to do

• Analyze slow pages with tools like YSlow

• Analyze network infrastructure. Compare server side times vs. Client side times

Analyze Page Size Statistics Analyze individual page objects

Page 17: SharePoint TechCon 2009 - 803

17dynaTrace

NEVER TESTED with REAL WORLD data

• Importance of Test Data• 10 records in a table are not enough• Invest time to generate Test Data• „Random“ data is good -> „Realistic“ data is best• Test Data must be used by developers• Many data access problems can be identified on the developers machine with

appropriate test data

• Problems that can be identified• Performance problems for data retrieval• Index problems• Memory issues• Resource bottlenecks

• Resources• http://www.sharepointblogs.com/ethan/archive/2007/09/27/generating-test-

data.aspx• http://www.idevfactory.com/• http://www.codeplex.com/sptdatapop

Page 18: SharePoint TechCon 2009 - 803

18dynaTrace

NEVER TESTED UNDER LOAD

• Importance of Load Testing

• Small load tests already on developers machine

• Test as early as possible

• Test main use case scenarios

• Visual Studio Team System for Tester

• Pre-configured Web&Load Tests from the SharePoint Team

• dynaTrace Integration with VSTS to analyze performance and scalability issues

• Resources

• http://www.codeplex.com/sptdatapop

Page 19: SharePoint TechCon 2009 - 803

19dynaTrace

NEVER TESTED UNDER LOAD

• Load Testing SharePoint with Visual Studio Team System

DEMO

Page 20: SharePoint TechCon 2009 - 803

20dynaTrace

Contact me for follow up

• Andreas Grabner

• Mail: [email protected]

• Blog: http://blog.dynatrace.com

• Web: http://www.dynatrace.com

Participate in Performance Survey

and win a price at the dynaTrace Booth