SlideShare ist ein Scribd-Unternehmen logo
1 von 104
Downloaden Sie, um offline zu lesen
Techniques, tips and tools for improve
and measure web performance.
Web Performance Optimization
Workshop - MercadoLibre
Santiago Aimetta
Nicolas Brizuela
Pablo Moretti
Why performance?
Reducing time to response, impact
directly in your revenues.
Impact directly in the bounce rate,
conversions rate and is very important for
user experience.
Amazon test 2008
● + 100ms >> -1% sales
Bing test 2009
● + 2000ms >> -4.3% revenues/user
MercadoLibre 2013
● + 3000ms >> + 3% in Bounce rate
-1% in Revenues
Performance golden rules
● 80-90% of the end-user response time is spent on the
frontend.
We start there
● Greater potential
● Simple
● Proven to work
Responsibilities
Time to First Byte
What is this?
Is the amount of time between the client
makes an HTTP request and the browser
starts receiving the first byte.
How much time is spent making the
request until receive the first byte of the
response.
1. DNS LOOKUP
2. INITIAL CONNECTION
3. WAITING
4. RECEIVING DATA
5. CLOSING CONNECTION
1. DNS LOOKUP
2. INITIAL CONNECTION
3. WAITING
4. RECEIVING DATA
5. CLOSING CONNECTION
1. DNS LOOKUP
2. INITIAL CONNECTION
3. WAITING
4. RECEIVING DATA
5. CLOSING CONNECTION
1. DNS LOOKUP
2. INITIAL CONNECTION
3. WAITING
4. RECEIVING DATA
5. CLOSING CONNECTION
1. DNS LOOKUP
2. INITIAL CONNECTION
3. WAITING
4. RECEIVING DATA
5. CLOSING CONNECTION
<< Time to first Byte = TTFB
Expected values
● Static content
○ Such as Html, Js, Css and images
○ Should be under 100 miliseconds
● Dinamic content
○ Includes all the server side processing plus the
network infrastructure work
○ Should be beetween 200 and 500 miliseconds
Possible problems
● To many connections to the server
● Disk IO
Hardware check..
● Disk IO
● RAM usage
● Swap usage
● Network bottlenecks
Configuration check..
● Webserver config (Apache,Jboss,..) / Php config
● Database settings
● Network settings
● Api / webservices latency
How to improve it?
Hardware
● CDN- Content delivery network (Akamai,
CloudFront, BitGravity)
● Multiple servers with load balancing ( f5 , nginx )
● NAS - Filers ( T-com, IBM, HP)
● Web caches ( Varnish, Polipo, Squid, TrafficServer )
Software
● Parallel processing
● Database tuning
● Sql tuning
● API / Webservices response caching
● NoSql (MongoDB, Bigtable, Redis)
● Chunking - Early buffer flush
Tools
Analyzers
● Google Page Speed
● WebPageTest
● Firebug
Custom measuring
● Navigation timing api
var timing = window.performance.timing;
var ttfb = timing.responseStart -timing.connectEnd;
CDN (Content Delivery Network)
● Group of servers distributed in multiple datacenters
across the internet
● The CDN serves the content using the servers that
are closer to the client
● The network latency is reduced by the proximity
between client and server.
● The resources can be cached
● Multiple servers prevent bottlenecks
● Useful for static resources like Html, Css, fonts , Js,
videos , images, documents, etc
GZIP (HTTP compression)
● Type of http compression like deflate
● This saves bandwidth and increases speed.
● Web client (i.e Browser) sends an Accept-Encoding :
gzip, deflate header
● Web server responds Content-Encoding : gzip if the
data is compressed
● Reduce the 70%-90% of the response size
● Use in Html, Css, Js, Xml, Json
● Dont use in Pdf and images, they are already
compressed
● Better compression tips:
○ Sorted key values : Css, html attributes
○ use one type of quotes, " or '
○ Css and Js minification
Cache
Benefits
● Saves requests to resources that changes
infrequently.
● HTTP caching saves the resources in the
browser or the proxy.
● Should be cached: CSS, JS, Static HTML, Images,
Flash, Pdf, media files.
How it works?
How it works?
Response Headers
● Strong ones:
○ These headers express the resource lifetime.
○ The value is a date or a timestamp.
○ A resource is downloaded again when the
expiration date is reached.
○ Expires and Cache Control.
Response Headers
● Weak ones:
○ Specifies characteristics to identify if the
resource change
○ The browser sends conditional GETs to check
○ Last-Modified, Etag
Cache Control
● Strong header
● Cache-Control:public
● Cache-Control:private
● i.e: Cache-Control:public, max-age=3600
Expires
● Sets an expiration date in the future.
● if Cache-control and expires are set for the same.
resource Cache-control takes precedence.
● i.e: Expires: Mon, 8 Jul 2013 21:31:12 GMT.
Last modified
● Is a time based header.
● The application specifies the last modified header
i.e: Last-Modified: Tue, 09 jul 2013 17:45:57 GMT.
● The next time the browser sends a conditional GET
asking if the resource has changed
i.e If-Modified-Since: Tue, 09 jul 2013 17:45:57 GMT.
● If the resource hasn't changed the server return an
empty response with the 304 code (Not Modified)
Etag
● Use an md5 hash to identify if the resource change.
ETag: "15f0fff99ed5aae4edffdd6496d7131f".
● In the next request the header If-None-Match is sent
with the ETag value
i.e: If-None-Match: "15f0fff99ed5aae4edffdd6496d7131f"
● If the ETag match, the server responds 304
Tools
● Most of browser tools has a network analyzer
● The example below were made with Chrome dev tool
Tips
● For static content: use Cache-Control.
● Cache-Control is easy to check.
● Avoid conditional Gets.
● Use the app version or a fingerprint in the url.
Tips
● For private content: use Cache-Control :
private to avoid proxy caching.
● Prevent caching: use Cache-Control:no-cache,
no-store.
● Urls with query string.
Keep alive (reuse connections)
● Client and server keep the connection open,
unless the client indicates otherwise (via
Connection: close header).
● Http connections are expensive.
● Saves TCP handshake ( 150 ms average ).
● Persistent connections send multiple request and
response interactions over single connection.
● If the connection is not persistent you can specify a
time out.
Persisten connection
Advantages
● CPU & memory savings, less tcp connections and
fewer TCP control blocks.
● Allows request and response pipelining.
● Reduce network load, less packets sent.
● Supported by modern browsers.
Parallel downloads
The biggest impact on end-user response
times is the number of components in the
page
How it works?
● Images can be downloaded in parallel
● JS and CSS..other story
● Loading steps
○ downloading (can be parallel )
○ parsing
○ executing
● Rules
○ Scripts prevents other scripts to be downloaded
and parsed
○ Stylessheets prevent scripts to be downloaded
and parsed
○ Modern browsers start looking ahead in the
document and pre-loading stylesheets and scripts
The HTTP/1.1 RFC
A single-user client SHOULD NOT
maintain more than 2 connections with
any server or proxy.
The HTTP/1.1 RFC
A single-user client SHOULD NOT
maintain more than 2 connections with
any server or proxy.
IE 6 and 7: 2
IE 8: 6
IE 9: 6
IE 10: 8
Firefox 2: 2
Firefox 3: 6
Firefox 4 to 17: 6
Opera 9.63: 4
Opera 10: 8
Opera 11 and 12: 6
Chrome 1 and 2: 6
Chrome 3: 4
Chrome 4 to 28: 6
Safari 3 and 4: 4
How browsers handle it?
● Browsers don't have to follow
this guideline.
● Parallel connections.
Nice trick!
● The number of parallel connections applies to a
server.
● Use multiple domain names
○ i.e resources1.domain.com, resources2.
domain.com
○ Expands per server connection limit.
○ If the domains are CNAMEs of the same ip,
works too!
Nice trick!
Trade off
● DNS lookup ~ 150 ms
● Browser cpu per parallel download
● Bandwidth
Reduce client request time by reducing the
request size
Small request
Objective
● Minimize the request overhead
● Cut down on client request time by reducing the
number of bytes uploaded as request header data
● Average request size is 1500 bytes.
How
● Keeping cookies and request headers as small as
possible ensures that an HTTP request can fit into a
single packet.
● Small urls.
● Small cookies.
● Remove unused header.
For static content
Cookieless domain
Static content
● Objective:
○ If you set a cookie in particular domain, all
subsequent HTTP requests for that domain must
include the cookie.
○ Static content, such as images, JS and CSS files,
don't need to be accompanied by cookies.
○ Avoid caching user info.
Static content
● How:
○ Create a domain for static content
○ Use caching headers
○ CDNs avoid cookies
Use browser idle time
Prefetching
Objective
● Use the browser idle time to download or
prefetch documents that the user might visit in
the near future.
Which content prefetch?
● Images commonly used.
● The next page of the search results.
● Prefetch common DNS.
● Image:
● Full page
● DNS
● Be aware of
○ Bandwidth, website statistics
Where and why
Javascript load & execution
Where to load?
Where and why?
● In the head: RUM, analytics
● before </body>: scripts needed by page load
● After page load: scripts needed soon after
page load
● On demand: In reaction to users
With and without blocking
Javascript loading
Motivation
● Scripts blocks downloads and render.
Several ways avoid it
● XHR Eval
● XHR Injection
● Script in Iframe
● Script DOM Element
● Script Defer
Avoid blocking - Simple approach
Avoid blocking - adding a callback
Avoid blocking - adding a callback
Avoid blocking - cross browser
Avoid blocking - onload event
● Blocks onload event until the script have been
downloaded and executed
○ script defer
○ script async
○ script dom element
● Fix
○ If you want to ensure that the JavaScript doesn't
start to download or execute until after the load
event, you can insert it using the window.onload
event handler:
Avoid blocking - onload event
Sometimes the image weight its 40-50% of
the complete page weight
Image Optimization
Lossless optimizations
● Are those that take an image and produce another
image, which renders exactly the same and it's
smaller in file size than the original
● The lossless file size savings come from:
○ Using better compression algorithms to store the
pixel information.
○ Removing unneeded metadata that goes with the
image file.
GIF
● The best way to optimize a GIF image is to convert it
to PNG8.
● It can store up to 256 colors, just like GIF.
● PNG8 supports alpha transparency.
● Software:
○ Photoshop
○ OptiPNG
● Animated GIF
○ Don't convert to PNG
○ Software:
■ GIFSicle
JPEG
● Edit image metadata
○ Software: JPEGTran, EXIFTool
● Optimizing compression
○ Software: JPEGTran
● Cropping
○ Rotation to 90, 180, 270 degrees
PNG
● Icons, illustrations and photos with high contrast.
● Support transparency (alpha channel).
● Optimizations
○ Strip PNG chunks
○ Better pixel compression
● Software
○ TinyPNG
○ OptiPNG
○ PNGOptimizer
● Stoyan test over 1000 sites
○ Convert GIFs to PNG ( -23% )
○ PNG optimization tools ( -17% )
○ Run JPEGTran on all JPEGs ( -13% )
○ Optimize animations with GIFSicle ( -4% )
JPEG Progressive
Perceived speed is more important that actual speed
JPEG Progressive
● Two types of images, baseline and progressive
● Baseline jpeg: is a full-resolution top-to-bottom scan
of the image
JPEG Progressive
● Progressive jpeg: is a series of scans of increasing
quality, loads from low quality to high in several
"passes"
JPEG Progressive
● The progressive jpeg’s first pass is low-resolution, but
it contains as much information, or more, as the small
image
● Software:
○ jpegtran
○ jpegcrop
● Images of file size 10K and over have a better chance
of being smaller when using the progressive JPEG
format
WebP
A new image format for the Web
WebP
● What is?
○ is a new image format that provides lossless and
lossy compression for images on the web
● 26% smaller than PNG
● 25-34% smaller than JPEG
● Supports transparency ( alpha channel )
WebP
● Software
○ CwebP
○ DwebP
○ libwebp
● Support
○ Chrome 9+
○ Opera 12+
○ Android 4+
○ Opera mobile 11+
○ Chrome for android 27+
Muchas gracias!!!
Links
● http://www.rackaid.com/resources/time-to-
first-byte/
● http://jackwhitey.hubpages.com/hub/cdn
● https://developers.google.
com/speed/articles/gzip
● https://devcenter.heroku.
com/articles/increasing-application-
performance-with-http-cache-headers#http-
cache-headers
● https://developers.google.
com/speed/docs/best-practices/caching
Links
● http://www.nczonline.
net/blog/2009/06/23/loading-javascript-
without-blocking/
● http://www.stevesouders.
com/blog/2009/04/27/loading-scripts-without-
blocking/
● http://www.stevesouders.
com/blog/2008/12/27/coupling-async-scripts/
● http://calendar.perfplanet.com/2010/the-
truth-about-non-blocking-javascript/
Links
● http://www.igvita.com/2011/10/04/optimizing-
http-keep-alive-and-pipelining/
● http://tools.ietf.org/id/draft-thomson-hybi-
http-timeout-01.html#rfc.section.2
● http://www.dcs.bbk.ac.
uk/~ptw/teaching/http/slide15.html
● http://www.dcs.bbk.ac.
uk/~ptw/teaching/http/slide16.html
● http://abdussamad.com/archives/169-
Apache-optimization:-KeepAlive-On-or-Off.
html
Links
● http://davidwalsh.name/javascript-domready
● http://api.jquery.com/ready/
● http://alexsexton.com/blog/2010/01/dont-let-
document-ready-slow-you-down/
● https://developers.google.
com/speed/docs/best-practices/request
● http://www.nczonline.
net/blog/2009/05/05/http-cookies-explained/
Links
● http://www.catswhocode.
com/blog/mastering-html5-prefetching
● http://davidwalsh.name/dns-prefetching
● http://davidwalsh.name/html5-prefetch
● http://statichtml.com/2011/link-prefetching-
broken-in-chrome.html
● http://www.bookofspeed.com/chapter5.html
● http://calendar.perfplanet.
com/2012/progressive-jpegs-a-new-best-
practice/
Links
● http://caniuse.com/webp
● https://developers.google.com/speed/webp/?
hl=es-ES
● http://news.cnet.com/8301-1023_3-
57585114-93/google-cuts-network-usage-
by-terabytes-by-switching-to-webp/
● https://developers.google.com/speed/spdy/
● http://www.chromium.org/spdy
● http://googlecode.blogspot.com.
ar/2012/01/making-web-speedier-and-safer-
with-spdy.html
Links
● http://dev.chromium.org/spdy/spdy-best-
practices
● http://www.slideshare.net/nzakas/enough-
withthejavascriptalready
● http://ejohn.org/blog/browser-page-load-
performance/
● http://www.stevesouders.
com/blog/2008/03/20/roundup-on-parallel-
connections/
● http://www.yuiblog.
com/blog/2007/04/11/performance-research-

Weitere ähnliche Inhalte

Was ist angesagt?

Reverse proxy & web cache with NGINX, HAProxy and Varnish
Reverse proxy & web cache with NGINX, HAProxy and VarnishReverse proxy & web cache with NGINX, HAProxy and Varnish
Reverse proxy & web cache with NGINX, HAProxy and VarnishEl Mahdi Benzekri
 
Service workers - Velocity 2016 Training
Service workers - Velocity 2016 TrainingService workers - Velocity 2016 Training
Service workers - Velocity 2016 TrainingPatrick Meenan
 
NGINX for Application Delivery & Acceleration
NGINX for Application Delivery & AccelerationNGINX for Application Delivery & Acceleration
NGINX for Application Delivery & AccelerationNGINX, Inc.
 
Zingme practice for building scalable website with PHP
Zingme practice for building scalable website with PHPZingme practice for building scalable website with PHP
Zingme practice for building scalable website with PHPChau Thanh
 
Benchmarking NGINX for Accuracy and Results
Benchmarking NGINX for Accuracy and ResultsBenchmarking NGINX for Accuracy and Results
Benchmarking NGINX for Accuracy and ResultsNGINX, Inc.
 
University of Delaware - Improving Web Protocols (early SPDY talk)
University of Delaware - Improving Web Protocols (early SPDY talk)University of Delaware - Improving Web Protocols (early SPDY talk)
University of Delaware - Improving Web Protocols (early SPDY talk)Mike Belshe
 
Mailerqnewpresentation
MailerqnewpresentationMailerqnewpresentation
MailerqnewpresentationCopernica BV
 
AJAX for Scalability
AJAX for ScalabilityAJAX for Scalability
AJAX for ScalabilityTuenti
 
SPA2015: Hooman Beheshti – The Future of CDNs
SPA2015: Hooman Beheshti – The Future of CDNsSPA2015: Hooman Beheshti – The Future of CDNs
SPA2015: Hooman Beheshti – The Future of CDNsFastly
 
Measuring CDN performance and why you're doing it wrong
Measuring CDN performance and why you're doing it wrongMeasuring CDN performance and why you're doing it wrong
Measuring CDN performance and why you're doing it wrongFastly
 
Supercharge Application Delivery to Satisfy Users
Supercharge Application Delivery to Satisfy UsersSupercharge Application Delivery to Satisfy Users
Supercharge Application Delivery to Satisfy UsersNGINX, Inc.
 
Nginx Scalable Stack
Nginx Scalable StackNginx Scalable Stack
Nginx Scalable StackBruno Paiuca
 
Nginx: Accelerate Rails, HTTP Tricks
Nginx: Accelerate Rails, HTTP TricksNginx: Accelerate Rails, HTTP Tricks
Nginx: Accelerate Rails, HTTP TricksAdam Wiggins
 

Was ist angesagt? (17)

Reverse proxy & web cache with NGINX, HAProxy and Varnish
Reverse proxy & web cache with NGINX, HAProxy and VarnishReverse proxy & web cache with NGINX, HAProxy and Varnish
Reverse proxy & web cache with NGINX, HAProxy and Varnish
 
Service workers - Velocity 2016 Training
Service workers - Velocity 2016 TrainingService workers - Velocity 2016 Training
Service workers - Velocity 2016 Training
 
Http caching
Http cachingHttp caching
Http caching
 
NGINX for Application Delivery & Acceleration
NGINX for Application Delivery & AccelerationNGINX for Application Delivery & Acceleration
NGINX for Application Delivery & Acceleration
 
Zingme practice for building scalable website with PHP
Zingme practice for building scalable website with PHPZingme practice for building scalable website with PHP
Zingme practice for building scalable website with PHP
 
Benchmarking NGINX for Accuracy and Results
Benchmarking NGINX for Accuracy and ResultsBenchmarking NGINX for Accuracy and Results
Benchmarking NGINX for Accuracy and Results
 
University of Delaware - Improving Web Protocols (early SPDY talk)
University of Delaware - Improving Web Protocols (early SPDY talk)University of Delaware - Improving Web Protocols (early SPDY talk)
University of Delaware - Improving Web Protocols (early SPDY talk)
 
HTTP/2 Prioritization
HTTP/2 PrioritizationHTTP/2 Prioritization
HTTP/2 Prioritization
 
Mailerqnewpresentation
MailerqnewpresentationMailerqnewpresentation
Mailerqnewpresentation
 
AJAX for Scalability
AJAX for ScalabilityAJAX for Scalability
AJAX for Scalability
 
Advanced Drupal 8 Caching
Advanced Drupal 8 CachingAdvanced Drupal 8 Caching
Advanced Drupal 8 Caching
 
SPA2015: Hooman Beheshti – The Future of CDNs
SPA2015: Hooman Beheshti – The Future of CDNsSPA2015: Hooman Beheshti – The Future of CDNs
SPA2015: Hooman Beheshti – The Future of CDNs
 
Measuring CDN performance and why you're doing it wrong
Measuring CDN performance and why you're doing it wrongMeasuring CDN performance and why you're doing it wrong
Measuring CDN performance and why you're doing it wrong
 
Supercharge Application Delivery to Satisfy Users
Supercharge Application Delivery to Satisfy UsersSupercharge Application Delivery to Satisfy Users
Supercharge Application Delivery to Satisfy Users
 
Nginx Scalable Stack
Nginx Scalable StackNginx Scalable Stack
Nginx Scalable Stack
 
Nginx: Accelerate Rails, HTTP Tricks
Nginx: Accelerate Rails, HTTP TricksNginx: Accelerate Rails, HTTP Tricks
Nginx: Accelerate Rails, HTTP Tricks
 
Caching in HTTP
Caching in HTTPCaching in HTTP
Caching in HTTP
 

Ähnlich wie Web performance optimization - MercadoLibre

SPDY and What to Consider for HTTP/2.0
SPDY and What to Consider for HTTP/2.0SPDY and What to Consider for HTTP/2.0
SPDY and What to Consider for HTTP/2.0Mike Belshe
 
Drupal 7 performance and optimization
Drupal 7 performance and optimizationDrupal 7 performance and optimization
Drupal 7 performance and optimizationShafqat Hussain
 
Website & Internet + Performance testing
Website & Internet + Performance testingWebsite & Internet + Performance testing
Website & Internet + Performance testingRoman Ananev
 
Breaking the Speed Limit: Faster Websites Win
Breaking the Speed Limit: Faster Websites WinBreaking the Speed Limit: Faster Websites Win
Breaking the Speed Limit: Faster Websites WinJonathan Hochman
 
Understanding Page Load / Ziling Zhao (Google)
Understanding Page Load / Ziling Zhao (Google)Understanding Page Load / Ziling Zhao (Google)
Understanding Page Load / Ziling Zhao (Google)Ontico
 
20 tips for website performance
20 tips for website performance20 tips for website performance
20 tips for website performanceAndrew Siemer
 
PyGrunn2013 High Performance Web Applications with TurboGears
PyGrunn2013  High Performance Web Applications with TurboGearsPyGrunn2013  High Performance Web Applications with TurboGears
PyGrunn2013 High Performance Web Applications with TurboGearsAlessandro Molina
 
Scaling Up with PHP and AWS
Scaling Up with PHP and AWSScaling Up with PHP and AWS
Scaling Up with PHP and AWSHeath Dutton ☕
 
Configuring Apache Servers for Better Web Perormance
Configuring Apache Servers for Better Web PerormanceConfiguring Apache Servers for Better Web Perormance
Configuring Apache Servers for Better Web PerormanceSpark::red
 
AWS Summit London 2014 | Dynamic Content Acceleration (300)
AWS Summit London 2014 | Dynamic Content Acceleration (300)AWS Summit London 2014 | Dynamic Content Acceleration (300)
AWS Summit London 2014 | Dynamic Content Acceleration (300)Amazon Web Services
 
Dynamic Content Acceleration: Lightning Fast Web Apps with Amazon CloudFront ...
Dynamic Content Acceleration: Lightning Fast Web Apps with Amazon CloudFront ...Dynamic Content Acceleration: Lightning Fast Web Apps with Amazon CloudFront ...
Dynamic Content Acceleration: Lightning Fast Web Apps with Amazon CloudFront ...Amazon Web Services
 
SANDcamp 2014 - A Perfect Launch, Every Time
SANDcamp 2014 - A Perfect Launch, Every TimeSANDcamp 2014 - A Perfect Launch, Every Time
SANDcamp 2014 - A Perfect Launch, Every TimeJon Peck
 
What is Nginx and Why You Should to Use it with Wordpress Hosting
What is Nginx and Why You Should to Use it with Wordpress HostingWhat is Nginx and Why You Should to Use it with Wordpress Hosting
What is Nginx and Why You Should to Use it with Wordpress HostingWPSFO Meetup Group
 
Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) ...
Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) ...Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) ...
Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) ...Amazon Web Services
 
kranonit S06E01 Игорь Цинько: High load
kranonit S06E01 Игорь Цинько: High loadkranonit S06E01 Игорь Цинько: High load
kranonit S06E01 Игорь Цинько: High loadKrivoy Rog IT Community
 
Spreadshirt Techcamp 2018 - Hold until Told
Spreadshirt Techcamp 2018 - Hold until ToldSpreadshirt Techcamp 2018 - Hold until Told
Spreadshirt Techcamp 2018 - Hold until ToldMartin Breest
 
Word press optimizations
Word press optimizations Word press optimizations
Word press optimizations Shawn DeWolfe
 
Imagine 2014: The Devil is in the Details How to Optimize Magento Hosting to ...
Imagine 2014: The Devil is in the Details How to Optimize Magento Hosting to ...Imagine 2014: The Devil is in the Details How to Optimize Magento Hosting to ...
Imagine 2014: The Devil is in the Details How to Optimize Magento Hosting to ...George White
 
Developing high performance and responsive web apps using web worker
Developing high performance and responsive web apps using web workerDeveloping high performance and responsive web apps using web worker
Developing high performance and responsive web apps using web workerSuresh Patidar
 

Ähnlich wie Web performance optimization - MercadoLibre (20)

SPDY and What to Consider for HTTP/2.0
SPDY and What to Consider for HTTP/2.0SPDY and What to Consider for HTTP/2.0
SPDY and What to Consider for HTTP/2.0
 
Web Performance Optimization
Web Performance OptimizationWeb Performance Optimization
Web Performance Optimization
 
Drupal 7 performance and optimization
Drupal 7 performance and optimizationDrupal 7 performance and optimization
Drupal 7 performance and optimization
 
Website & Internet + Performance testing
Website & Internet + Performance testingWebsite & Internet + Performance testing
Website & Internet + Performance testing
 
Breaking the Speed Limit: Faster Websites Win
Breaking the Speed Limit: Faster Websites WinBreaking the Speed Limit: Faster Websites Win
Breaking the Speed Limit: Faster Websites Win
 
Understanding Page Load / Ziling Zhao (Google)
Understanding Page Load / Ziling Zhao (Google)Understanding Page Load / Ziling Zhao (Google)
Understanding Page Load / Ziling Zhao (Google)
 
20 tips for website performance
20 tips for website performance20 tips for website performance
20 tips for website performance
 
PyGrunn2013 High Performance Web Applications with TurboGears
PyGrunn2013  High Performance Web Applications with TurboGearsPyGrunn2013  High Performance Web Applications with TurboGears
PyGrunn2013 High Performance Web Applications with TurboGears
 
Scaling Up with PHP and AWS
Scaling Up with PHP and AWSScaling Up with PHP and AWS
Scaling Up with PHP and AWS
 
Configuring Apache Servers for Better Web Perormance
Configuring Apache Servers for Better Web PerormanceConfiguring Apache Servers for Better Web Perormance
Configuring Apache Servers for Better Web Perormance
 
AWS Summit London 2014 | Dynamic Content Acceleration (300)
AWS Summit London 2014 | Dynamic Content Acceleration (300)AWS Summit London 2014 | Dynamic Content Acceleration (300)
AWS Summit London 2014 | Dynamic Content Acceleration (300)
 
Dynamic Content Acceleration: Lightning Fast Web Apps with Amazon CloudFront ...
Dynamic Content Acceleration: Lightning Fast Web Apps with Amazon CloudFront ...Dynamic Content Acceleration: Lightning Fast Web Apps with Amazon CloudFront ...
Dynamic Content Acceleration: Lightning Fast Web Apps with Amazon CloudFront ...
 
SANDcamp 2014 - A Perfect Launch, Every Time
SANDcamp 2014 - A Perfect Launch, Every TimeSANDcamp 2014 - A Perfect Launch, Every Time
SANDcamp 2014 - A Perfect Launch, Every Time
 
What is Nginx and Why You Should to Use it with Wordpress Hosting
What is Nginx and Why You Should to Use it with Wordpress HostingWhat is Nginx and Why You Should to Use it with Wordpress Hosting
What is Nginx and Why You Should to Use it with Wordpress Hosting
 
Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) ...
Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) ...Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) ...
Dynamic Content Acceleration: Amazon CloudFront and Amazon Route 53 (ARC309) ...
 
kranonit S06E01 Игорь Цинько: High load
kranonit S06E01 Игорь Цинько: High loadkranonit S06E01 Игорь Цинько: High load
kranonit S06E01 Игорь Цинько: High load
 
Spreadshirt Techcamp 2018 - Hold until Told
Spreadshirt Techcamp 2018 - Hold until ToldSpreadshirt Techcamp 2018 - Hold until Told
Spreadshirt Techcamp 2018 - Hold until Told
 
Word press optimizations
Word press optimizations Word press optimizations
Word press optimizations
 
Imagine 2014: The Devil is in the Details How to Optimize Magento Hosting to ...
Imagine 2014: The Devil is in the Details How to Optimize Magento Hosting to ...Imagine 2014: The Devil is in the Details How to Optimize Magento Hosting to ...
Imagine 2014: The Devil is in the Details How to Optimize Magento Hosting to ...
 
Developing high performance and responsive web apps using web worker
Developing high performance and responsive web apps using web workerDeveloping high performance and responsive web apps using web worker
Developing high performance and responsive web apps using web worker
 

Mehr von Pablo Moretti

Scaling with Microservice
Scaling with MicroserviceScaling with Microservice
Scaling with MicroservicePablo Moretti
 
Mobiledevcon - MercadoLibre web mobile
Mobiledevcon - MercadoLibre web mobileMobiledevcon - MercadoLibre web mobile
Mobiledevcon - MercadoLibre web mobilePablo Moretti
 
Breaking performance web rules
Breaking performance web rulesBreaking performance web rules
Breaking performance web rulesPablo Moretti
 
Demanda - MercadoLivre Developers Conference
Demanda - MercadoLivre Developers ConferenceDemanda - MercadoLivre Developers Conference
Demanda - MercadoLivre Developers ConferencePablo Moretti
 
Mercado Libre - Introducción a SEO
Mercado Libre - Introducción a SEOMercado Libre - Introducción a SEO
Mercado Libre - Introducción a SEOPablo Moretti
 
Efficiently downloading and executing Javascript
Efficiently downloading and executing JavascriptEfficiently downloading and executing Javascript
Efficiently downloading and executing JavascriptPablo Moretti
 

Mehr von Pablo Moretti (7)

Scaling with Microservice
Scaling with MicroserviceScaling with Microservice
Scaling with Microservice
 
Mobiledevcon - MercadoLibre web mobile
Mobiledevcon - MercadoLibre web mobileMobiledevcon - MercadoLibre web mobile
Mobiledevcon - MercadoLibre web mobile
 
Breaking performance web rules
Breaking performance web rulesBreaking performance web rules
Breaking performance web rules
 
Demanda - MercadoLivre Developers Conference
Demanda - MercadoLivre Developers ConferenceDemanda - MercadoLivre Developers Conference
Demanda - MercadoLivre Developers Conference
 
Groovy & Java
Groovy & JavaGroovy & Java
Groovy & Java
 
Mercado Libre - Introducción a SEO
Mercado Libre - Introducción a SEOMercado Libre - Introducción a SEO
Mercado Libre - Introducción a SEO
 
Efficiently downloading and executing Javascript
Efficiently downloading and executing JavascriptEfficiently downloading and executing Javascript
Efficiently downloading and executing Javascript
 

Kürzlich hochgeladen

04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 

Kürzlich hochgeladen (20)

04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 

Web performance optimization - MercadoLibre

  • 1. Techniques, tips and tools for improve and measure web performance. Web Performance Optimization Workshop - MercadoLibre Santiago Aimetta Nicolas Brizuela Pablo Moretti
  • 2. Why performance? Reducing time to response, impact directly in your revenues. Impact directly in the bounce rate, conversions rate and is very important for user experience.
  • 3. Amazon test 2008 ● + 100ms >> -1% sales Bing test 2009 ● + 2000ms >> -4.3% revenues/user MercadoLibre 2013 ● + 3000ms >> + 3% in Bounce rate -1% in Revenues
  • 4.
  • 5. Performance golden rules ● 80-90% of the end-user response time is spent on the frontend. We start there ● Greater potential ● Simple ● Proven to work
  • 7.
  • 9. What is this? Is the amount of time between the client makes an HTTP request and the browser starts receiving the first byte. How much time is spent making the request until receive the first byte of the response.
  • 10. 1. DNS LOOKUP 2. INITIAL CONNECTION 3. WAITING 4. RECEIVING DATA 5. CLOSING CONNECTION
  • 11. 1. DNS LOOKUP 2. INITIAL CONNECTION 3. WAITING 4. RECEIVING DATA 5. CLOSING CONNECTION
  • 12. 1. DNS LOOKUP 2. INITIAL CONNECTION 3. WAITING 4. RECEIVING DATA 5. CLOSING CONNECTION
  • 13. 1. DNS LOOKUP 2. INITIAL CONNECTION 3. WAITING 4. RECEIVING DATA 5. CLOSING CONNECTION
  • 14. 1. DNS LOOKUP 2. INITIAL CONNECTION 3. WAITING 4. RECEIVING DATA 5. CLOSING CONNECTION << Time to first Byte = TTFB
  • 16. ● Static content ○ Such as Html, Js, Css and images ○ Should be under 100 miliseconds ● Dinamic content ○ Includes all the server side processing plus the network infrastructure work ○ Should be beetween 200 and 500 miliseconds
  • 17. Possible problems ● To many connections to the server ● Disk IO
  • 18. Hardware check.. ● Disk IO ● RAM usage ● Swap usage ● Network bottlenecks
  • 19. Configuration check.. ● Webserver config (Apache,Jboss,..) / Php config ● Database settings ● Network settings ● Api / webservices latency
  • 21. Hardware ● CDN- Content delivery network (Akamai, CloudFront, BitGravity) ● Multiple servers with load balancing ( f5 , nginx ) ● NAS - Filers ( T-com, IBM, HP) ● Web caches ( Varnish, Polipo, Squid, TrafficServer )
  • 22. Software ● Parallel processing ● Database tuning ● Sql tuning ● API / Webservices response caching ● NoSql (MongoDB, Bigtable, Redis) ● Chunking - Early buffer flush
  • 23. Tools
  • 24. Analyzers ● Google Page Speed ● WebPageTest ● Firebug
  • 25. Custom measuring ● Navigation timing api var timing = window.performance.timing; var ttfb = timing.responseStart -timing.connectEnd;
  • 27. ● Group of servers distributed in multiple datacenters across the internet ● The CDN serves the content using the servers that are closer to the client ● The network latency is reduced by the proximity between client and server.
  • 28.
  • 29. ● The resources can be cached ● Multiple servers prevent bottlenecks ● Useful for static resources like Html, Css, fonts , Js, videos , images, documents, etc
  • 31. ● Type of http compression like deflate ● This saves bandwidth and increases speed. ● Web client (i.e Browser) sends an Accept-Encoding : gzip, deflate header ● Web server responds Content-Encoding : gzip if the data is compressed
  • 32.
  • 33. ● Reduce the 70%-90% of the response size ● Use in Html, Css, Js, Xml, Json ● Dont use in Pdf and images, they are already compressed ● Better compression tips: ○ Sorted key values : Css, html attributes ○ use one type of quotes, " or ' ○ Css and Js minification
  • 34. Cache
  • 35. Benefits ● Saves requests to resources that changes infrequently. ● HTTP caching saves the resources in the browser or the proxy. ● Should be cached: CSS, JS, Static HTML, Images, Flash, Pdf, media files.
  • 38. Response Headers ● Strong ones: ○ These headers express the resource lifetime. ○ The value is a date or a timestamp. ○ A resource is downloaded again when the expiration date is reached. ○ Expires and Cache Control.
  • 39. Response Headers ● Weak ones: ○ Specifies characteristics to identify if the resource change ○ The browser sends conditional GETs to check ○ Last-Modified, Etag
  • 40. Cache Control ● Strong header ● Cache-Control:public ● Cache-Control:private ● i.e: Cache-Control:public, max-age=3600
  • 41. Expires ● Sets an expiration date in the future. ● if Cache-control and expires are set for the same. resource Cache-control takes precedence. ● i.e: Expires: Mon, 8 Jul 2013 21:31:12 GMT.
  • 42. Last modified ● Is a time based header. ● The application specifies the last modified header i.e: Last-Modified: Tue, 09 jul 2013 17:45:57 GMT. ● The next time the browser sends a conditional GET asking if the resource has changed i.e If-Modified-Since: Tue, 09 jul 2013 17:45:57 GMT. ● If the resource hasn't changed the server return an empty response with the 304 code (Not Modified)
  • 43. Etag ● Use an md5 hash to identify if the resource change. ETag: "15f0fff99ed5aae4edffdd6496d7131f". ● In the next request the header If-None-Match is sent with the ETag value i.e: If-None-Match: "15f0fff99ed5aae4edffdd6496d7131f" ● If the ETag match, the server responds 304
  • 44. Tools ● Most of browser tools has a network analyzer ● The example below were made with Chrome dev tool
  • 45. Tips ● For static content: use Cache-Control. ● Cache-Control is easy to check. ● Avoid conditional Gets. ● Use the app version or a fingerprint in the url.
  • 46. Tips ● For private content: use Cache-Control : private to avoid proxy caching. ● Prevent caching: use Cache-Control:no-cache, no-store. ● Urls with query string.
  • 47. Keep alive (reuse connections)
  • 48. ● Client and server keep the connection open, unless the client indicates otherwise (via Connection: close header). ● Http connections are expensive. ● Saves TCP handshake ( 150 ms average ).
  • 49. ● Persistent connections send multiple request and response interactions over single connection. ● If the connection is not persistent you can specify a time out.
  • 51. Advantages ● CPU & memory savings, less tcp connections and fewer TCP control blocks. ● Allows request and response pipelining. ● Reduce network load, less packets sent. ● Supported by modern browsers.
  • 52. Parallel downloads The biggest impact on end-user response times is the number of components in the page
  • 53. How it works? ● Images can be downloaded in parallel ● JS and CSS..other story
  • 54. ● Loading steps ○ downloading (can be parallel ) ○ parsing ○ executing ● Rules ○ Scripts prevents other scripts to be downloaded and parsed ○ Stylessheets prevent scripts to be downloaded and parsed ○ Modern browsers start looking ahead in the document and pre-loading stylesheets and scripts
  • 55. The HTTP/1.1 RFC A single-user client SHOULD NOT maintain more than 2 connections with any server or proxy.
  • 56. The HTTP/1.1 RFC A single-user client SHOULD NOT maintain more than 2 connections with any server or proxy.
  • 57. IE 6 and 7: 2 IE 8: 6 IE 9: 6 IE 10: 8 Firefox 2: 2 Firefox 3: 6 Firefox 4 to 17: 6 Opera 9.63: 4 Opera 10: 8 Opera 11 and 12: 6 Chrome 1 and 2: 6 Chrome 3: 4 Chrome 4 to 28: 6 Safari 3 and 4: 4 How browsers handle it? ● Browsers don't have to follow this guideline. ● Parallel connections.
  • 58. Nice trick! ● The number of parallel connections applies to a server. ● Use multiple domain names ○ i.e resources1.domain.com, resources2. domain.com ○ Expands per server connection limit. ○ If the domains are CNAMEs of the same ip, works too!
  • 60. Trade off ● DNS lookup ~ 150 ms ● Browser cpu per parallel download ● Bandwidth
  • 61. Reduce client request time by reducing the request size Small request
  • 62. Objective ● Minimize the request overhead ● Cut down on client request time by reducing the number of bytes uploaded as request header data ● Average request size is 1500 bytes.
  • 63. How ● Keeping cookies and request headers as small as possible ensures that an HTTP request can fit into a single packet. ● Small urls. ● Small cookies. ● Remove unused header.
  • 65. Static content ● Objective: ○ If you set a cookie in particular domain, all subsequent HTTP requests for that domain must include the cookie. ○ Static content, such as images, JS and CSS files, don't need to be accompanied by cookies. ○ Avoid caching user info.
  • 66. Static content ● How: ○ Create a domain for static content ○ Use caching headers ○ CDNs avoid cookies
  • 67. Use browser idle time Prefetching
  • 68. Objective ● Use the browser idle time to download or prefetch documents that the user might visit in the near future.
  • 69. Which content prefetch? ● Images commonly used. ● The next page of the search results. ● Prefetch common DNS.
  • 70. ● Image: ● Full page ● DNS ● Be aware of ○ Bandwidth, website statistics
  • 71. Where and why Javascript load & execution
  • 73. Where and why? ● In the head: RUM, analytics ● before </body>: scripts needed by page load ● After page load: scripts needed soon after page load ● On demand: In reaction to users
  • 74. With and without blocking Javascript loading
  • 75. Motivation ● Scripts blocks downloads and render.
  • 76. Several ways avoid it ● XHR Eval ● XHR Injection ● Script in Iframe ● Script DOM Element ● Script Defer
  • 77. Avoid blocking - Simple approach
  • 78. Avoid blocking - adding a callback
  • 79. Avoid blocking - adding a callback
  • 80. Avoid blocking - cross browser
  • 81. Avoid blocking - onload event ● Blocks onload event until the script have been downloaded and executed ○ script defer ○ script async ○ script dom element ● Fix ○ If you want to ensure that the JavaScript doesn't start to download or execute until after the load event, you can insert it using the window.onload event handler:
  • 82. Avoid blocking - onload event
  • 83. Sometimes the image weight its 40-50% of the complete page weight Image Optimization
  • 84. Lossless optimizations ● Are those that take an image and produce another image, which renders exactly the same and it's smaller in file size than the original ● The lossless file size savings come from: ○ Using better compression algorithms to store the pixel information. ○ Removing unneeded metadata that goes with the image file.
  • 85. GIF ● The best way to optimize a GIF image is to convert it to PNG8. ● It can store up to 256 colors, just like GIF. ● PNG8 supports alpha transparency. ● Software: ○ Photoshop ○ OptiPNG ● Animated GIF ○ Don't convert to PNG ○ Software: ■ GIFSicle
  • 86. JPEG ● Edit image metadata ○ Software: JPEGTran, EXIFTool ● Optimizing compression ○ Software: JPEGTran ● Cropping ○ Rotation to 90, 180, 270 degrees
  • 87. PNG ● Icons, illustrations and photos with high contrast. ● Support transparency (alpha channel). ● Optimizations ○ Strip PNG chunks ○ Better pixel compression ● Software ○ TinyPNG ○ OptiPNG ○ PNGOptimizer
  • 88. ● Stoyan test over 1000 sites ○ Convert GIFs to PNG ( -23% ) ○ PNG optimization tools ( -17% ) ○ Run JPEGTran on all JPEGs ( -13% ) ○ Optimize animations with GIFSicle ( -4% )
  • 89. JPEG Progressive Perceived speed is more important that actual speed
  • 90. JPEG Progressive ● Two types of images, baseline and progressive ● Baseline jpeg: is a full-resolution top-to-bottom scan of the image
  • 91. JPEG Progressive ● Progressive jpeg: is a series of scans of increasing quality, loads from low quality to high in several "passes"
  • 92. JPEG Progressive ● The progressive jpeg’s first pass is low-resolution, but it contains as much information, or more, as the small image ● Software: ○ jpegtran ○ jpegcrop ● Images of file size 10K and over have a better chance of being smaller when using the progressive JPEG format
  • 93. WebP A new image format for the Web
  • 94. WebP ● What is? ○ is a new image format that provides lossless and lossy compression for images on the web ● 26% smaller than PNG ● 25-34% smaller than JPEG ● Supports transparency ( alpha channel )
  • 95. WebP ● Software ○ CwebP ○ DwebP ○ libwebp ● Support ○ Chrome 9+ ○ Opera 12+ ○ Android 4+ ○ Opera mobile 11+ ○ Chrome for android 27+
  • 97.
  • 98. Links ● http://www.rackaid.com/resources/time-to- first-byte/ ● http://jackwhitey.hubpages.com/hub/cdn ● https://developers.google. com/speed/articles/gzip ● https://devcenter.heroku. com/articles/increasing-application- performance-with-http-cache-headers#http- cache-headers ● https://developers.google. com/speed/docs/best-practices/caching
  • 99. Links ● http://www.nczonline. net/blog/2009/06/23/loading-javascript- without-blocking/ ● http://www.stevesouders. com/blog/2009/04/27/loading-scripts-without- blocking/ ● http://www.stevesouders. com/blog/2008/12/27/coupling-async-scripts/ ● http://calendar.perfplanet.com/2010/the- truth-about-non-blocking-javascript/
  • 100. Links ● http://www.igvita.com/2011/10/04/optimizing- http-keep-alive-and-pipelining/ ● http://tools.ietf.org/id/draft-thomson-hybi- http-timeout-01.html#rfc.section.2 ● http://www.dcs.bbk.ac. uk/~ptw/teaching/http/slide15.html ● http://www.dcs.bbk.ac. uk/~ptw/teaching/http/slide16.html ● http://abdussamad.com/archives/169- Apache-optimization:-KeepAlive-On-or-Off. html
  • 101. Links ● http://davidwalsh.name/javascript-domready ● http://api.jquery.com/ready/ ● http://alexsexton.com/blog/2010/01/dont-let- document-ready-slow-you-down/ ● https://developers.google. com/speed/docs/best-practices/request ● http://www.nczonline. net/blog/2009/05/05/http-cookies-explained/
  • 102. Links ● http://www.catswhocode. com/blog/mastering-html5-prefetching ● http://davidwalsh.name/dns-prefetching ● http://davidwalsh.name/html5-prefetch ● http://statichtml.com/2011/link-prefetching- broken-in-chrome.html ● http://www.bookofspeed.com/chapter5.html ● http://calendar.perfplanet. com/2012/progressive-jpegs-a-new-best- practice/
  • 103. Links ● http://caniuse.com/webp ● https://developers.google.com/speed/webp/? hl=es-ES ● http://news.cnet.com/8301-1023_3- 57585114-93/google-cuts-network-usage- by-terabytes-by-switching-to-webp/ ● https://developers.google.com/speed/spdy/ ● http://www.chromium.org/spdy ● http://googlecode.blogspot.com. ar/2012/01/making-web-speedier-and-safer- with-spdy.html
  • 104. Links ● http://dev.chromium.org/spdy/spdy-best- practices ● http://www.slideshare.net/nzakas/enough- withthejavascriptalready ● http://ejohn.org/blog/browser-page-load- performance/ ● http://www.stevesouders. com/blog/2008/03/20/roundup-on-parallel- connections/ ● http://www.yuiblog. com/blog/2007/04/11/performance-research-