outsystems - when it's slow it sucks: lessons from the trenches - nextstep 2012
DESCRIPTION
Knowing your application has a performance problem is half the battle. Fixing the problem typically falls into one of several categories. In this session learn from performance problems encountered across the OutSystems ecosystem and the approach taken to find and address each issue.TRANSCRIPT
© outsystems 2012
When It's Slow it Sucks
Lessons Learned From the Trenches
© outsystems 2012
Good applications have at least one thing in common: they are really fast.
© outsystems 2012
© outsystems 2012
built-in agileplatform™
© outsystems 2012
viewstate reduction through R/W analysis partial screen rendering through visual AJAX
automatic AJAX queuing smart prevention of duplicated AJAX requests
automatic end-users activity monitoring
user interface logic database
agileplatform™
© outsystems 2012
unlimited horizontal scalability built-in distributed session management
automated batch processing scaling batch processes instrumentation & monitoring
integrations instrumentation & monitoring automatic monitoring of all errors
built-in logs rotation persistence of logs in bulk
asynchronous logging through messaging
user interface logic database
agileplatform™
© outsystems 2012
database connection pooling unused database connections unloading
optimized !elds fetch optimized dataset memory load
queries automatic instrumentation & monitoring primary & foreign keys automatic indexing
user interface logic database
agileplatform™
© outsystems 2012
Beyond built-in agileplatform™ optimizations,
keep these performance best practices in mind.
© outsystems 2012
la Palisse truth
© outsystems 2012
• Creating indexes for the most used entity attributes will signi!cantly improve the performance of select queries
– at the cost of slight overhead in insert and update operations.
la Palisse truth #1 Index your entities
© outsystems 2012
Lesson Learned From the Trenches
© outsystems 2012
Lesson Learned From the Trenches #1 Monitor your indexes
Uncover Hidden Data to Optimize Application Performance (Ian Stirk) http://msdn.microsoft.com/en-us/magazine/cc135978.aspx
SQL Server
© outsystems 2012
• Costly Missing Indexes – Indexes that you may consider adding
• Unused Indexes – Not needed indexes (they hurt performance too)
• Costly Used Indexes – Indexes hurting insert / update operations
Lesson Learned From the Trenches #1 Monitor your indexes
© outsystems 2012
• Reorganization of indexes and statistics update – Don't forget to involve the resident DBA.
la Palisse truth #2 Setup database maintenance plan
© outsystems 2012
the maintenance plan was being executed but…it was
stopping due to an error Inevitably, this was leading to performance degradation.
Lesson Learned From the Trenches #2 Ensure execution is being monitored
© outsystems 2012
• Avoid the use of 2000+ characters in a text !eld. – Data !elds greater than 2000 bytes are converted into a Text data
type.
• As a rule, isolate binary and/or large text !elds in separate entities
– And only retrieve them when they are strictly necessary
la Palisse truth #3 Isolate large text and binary data
© outsystems 2012
• allows fast and "exible indexing for keyword-based querying of text data
• also, To search inside the binary !les stored in database using I!lters
How-to install, con!gure and use Full Text Search agile network
Lesson Learned From the Trenches #3 Use Full-Text Search
© outsystems 2012
• Cross server joins are very inefficient. – The table in the linked server is completely loaded to the local DB in
order to perform the join.
• May be acceptable if the tables are small and unavoidable.
la Palisse truth #4 Don't join over linked server
© outsystems 2012
• Apply the recommended settings from the installation checklist.
la Palisse truth #5 Con!gure web server memory settings
© outsystems 2012
• Affects user experience, therefore should be simple and fast to execute.
• Also avoid using functions accessing the DB in Table/List Records.
la Palisse truth #6 Simplify screen preparations
© outsystems 2012
• Increases network traffic between the server and the browser.
la Palisse truth #7 Avoid using preparation data in screen actions
© outsystems 2012
• Use Service Studio’s build-in caching features (5.1+): – Queries – Actions
– Web blocks – Screens.
la Palisse truth # 8 Cache, baby, cache
© outsystems 2012
What about the lessons?
© outsystems 2012
la Palisse…The obvious
• Index your entities • Setup database maintenance plan • Isolate large text and binary data • Don't join over linked server • Con!gure web server memory settings • Simplify screen preparations • Avoid using preparation data in screen actions • Cache, baby, Cache
© outsystems 2012
80% of the end-user response time is spent on the browser
• downloading all the components in the page:
images, .css, scripts, flash, …
• The goal: Reducing the number of components in turn reduces the number of HTTP requests required to render the page
© outsystems 2012
Let’s start with…
© outsystems 2012
• The preferred method for reducing the number of image requests.
• Group multiple images together (usually icons or decorative images) into one sprite.
• Position the sprite to display the appropriate image by shifting the X or Y position by a multiple of the spacing.
Lesson Learned From the Trenches #4 CSS sprites
© outsystems 2012
Lesson Learned From the Trenches #4 CSS sprites
Enjoy the increased speed and reduced HTTP requests.
© outsystems 2012
• Moving stylesheets to the document HEAD makes pages appear to be loading faster, it allows the page to render progressively
• The problem with putting stylesheets near the bottom of the document is that it prohibits progressive rendering in many browsers
• Some browsers block rendering to avoid having to redraw elements of the page if their styles change.
Lesson Learned From the Trenches #5
Put Stylesheets at the Top
© outsystems 2012
• The problem caused by scripts is that they block parallel downloads.
• The HTTP/1.1 speci!cation suggests that browsers download no more than two components in parallel per hostname.
• While a script is downloading, the browser won't start any other downloads.
Lesson Learned From the Trenches #6
Put Scripts at the Bottom
© outsystems 2012
Lesson Learned From the Trenches #7 Minify CSS / JS !les
© outsystems 2012
Lesson Learned From the Trenches #7 really…minify it!
minifyjs.com jscompress.com
…
© outsystems 2012
• JavaScript and CSS !les are cached by the browser.
• JavaScript and CSS that are inlined in HTML documents get downloaded every time the HTML document is requested. – reduces the number of HTTP requests needed – increases the size of the HTML document.
Lesson Learned From the Trenches #8
Make JavaScript and CSS External
© outsystems 2012
Lessons Learned From the Trenches
© outsystems 2012
• Monitor your indexes • Ensure Database maintenance is being monitored • Use Full-Text Search • CSS sprites • Put Stylesheets at the Top • Put Scripts at the Bottom • Minify CSS / JS !les • Make JavaScript and CSS External
To keep in mind
© outsystems 2012
http://www.!ddler2.com/ http://yslow.org/ https://developers.google.com/speed/pagespeed/ http://www.websiteoptimization.com
search for…
© outsystems 2012
• How to tune the TCP/IP stack for high volume of web requests agile network
• Secrets to Building High Performance Apps nextstep11 presentation
• Spriting made easy http://spriteme.org/
• Automatic Performance Optimizations http://www.outsystems.com/demos
also search for…