SlideShare a Scribd company logo
WEB OPTIMIZATION:
 PARANOID MODE
   ROBIN@MINDTALK.COM
WHY SPEED MATTER?
“If it is fast and ugly,
 they will use it and
       curse you;
if it is slow, they will
       not use it.”
  --David Cheriton
WEB OPTIMIZATION
WEB OPTIMIZATION

• Minimizecost of investment by reducing
 processor and bandwidth usage.
WEB OPTIMIZATION

• Minimizecost of investment by reducing
 processor and bandwidth usage.

• User   satisfaction and customer engagement.
WEB OPTIMIZATION

• Minimizecost of investment by reducing
 processor and bandwidth usage.

• User   satisfaction and customer engagement.

• SEO:   Influence rank.
WHAT SHOULD WE DO?
OPTIMIZATION LEVEL:
     BEGINNER
• Avoid    redirection as possible.

• Client
       side caching: cache your static files
 includes: images, javascript, and stylesheet (css).

 • for example http header based by adding Etag
   or Last-Modified http header.

• Reduce    the number of DOM elements.
OPTIMIZATION LEVEL:
     MEDIUM
Minify your javascript and css

function login(){
  var inputUname = document.getElementById(“username”);
  var inputPass = document.getElementById(“password”);
  ajaxPost(“/login”, {“username”:inputUname,”password”:inputPass});
}




            function a(){
              var b, c, d;
              d = document.getElementById;
              b = d(“username”);
              c = d(“password”);
              ap(“/login”, {“username”:b,”password”:c});
            }
Minify your javascript and css
    Benchmark: compressing mindtalk.js
          original size: 4464 KB

      Tool            Minified    Save
 YUI Compressor        3440 KB   22%



  Google Closure
                       2712 KB   39%
Simple Optimization




  Google Closure
    Advanced           556 KB    87%
   Optimization
YUI Compressor
Google Closure Simple Optimization
Google Closure Advanced Optimization
Server side compression
              with Gzip




http://www.sendung.de/wp-content/compression.png
Server side compression
                    with Gzip


mindtalk.min.js       GZIP        mindtalk.min.js
       556 KB                     164 KB


                             NETWORK
“Wait..., how about performance?”
Server side compression
                     with Gzip

• Dynamic    Gzip Compression.

• Static   Gzip Compression.
Server side compression
                with Gzip
HOWTO Enable Static Gzip compression (NGINX):
Server side compression
                    with Gzip
HOWTO Enable Static Gzip compression (NGINX):

• Add   `gzip_static on;` in your nginx config file.
Server side compression
                    with Gzip
HOWTO Enable Static Gzip compression (NGINX):

• Add   `gzip_static on;` in your nginx config file.

• Compress   your static files manually, example:
Server side compression
                    with Gzip
HOWTO Enable Static Gzip compression (NGINX):

• Add   `gzip_static on;` in your nginx config file.

• Compress   your static files manually, example:

 •$gzip js/mindtalk.min.js > js/
  mindtalk.min.js.gz
Server side compression
                    with Gzip
HOWTO Enable Static Gzip compression (NGINX):

• Add   `gzip_static on;` in your nginx config file.

• Compress   your static files manually, example:

 •$gzip js/mindtalk.min.js > js/
  mindtalk.min.js.gz

• Done.
OPTIMIZATION LEVEL:
    ADVANCED
Image Compression
• Use   Progressive Compression for JPEG files.
Image Compression

HOWTO Use Progressive Compression
Combine javascript / CSS
Combine javascript / CSS
               HOWTO:

$ cat jquery.js jquery-plugins-wow.js jquery-
plugins-box.js > all.js
Chunking content (flush) socket
            write.
   1

                                 5
                        3

    2

                                 6

                        4
Chunking content (flush) socket
            write.



        Ruby     ios.flush



        PHP       flush();



       Python     flush()
DATABASE OPTIMIZATION
DATABASE OPTIMIZATION



Know your self and your enemy and you win!
                 --Sun Tzu

  Know your database and the bottleneck
             and you win!
              --unknown
DATABASE OPTIMIZATION
    HOWTO (MongoDB):
DATABASE OPTIMIZATION
                  HOWTO (MongoDB):

• Profiling   manually by setting profiling level:
DATABASE OPTIMIZATION
                  HOWTO (MongoDB):

• Profiling   manually by setting profiling level:

 •>   db.setProfilingLevel(2);
DATABASE OPTIMIZATION
                  HOWTO (MongoDB):

• Profiling   manually by setting profiling level:

 •>   db.setProfilingLevel(2);

• Profiling
         automatically by using Dex (MongoDB
 Index bot).
DATABASE OPTIMIZATION
                  HOWTO (MongoDB):

• Profiling   manually by setting profiling level:

 •>   db.setProfilingLevel(2);

• Profiling
         automatically by using Dex (MongoDB
 Index bot).

 •$ dex -f /var/log/mongodb.log mongodb://
  localhost/db
OPTIMIZATION LEVEL:
    PARANOID
USE NON BLOCKING I/O
THREAD BASED I/O

 worker worker worker worker




Client   Client   Client   Client   Client
THREAD BASED I/O

 worker worker worker worker




                                     WAITING

Client   Client   Client   Client   Client
NON BLOCKING EVENT BASED I/O




EVENT EMITTERS        IO LOOP                     EVENT HANDLER


                        Event Queue
              REQ
                                            REQ

                                      REQ
                       REQ    REQ




         Client     Client   Client    Client        Client
NON BLOCKING EVENT BASED I/O




               “CONFUSING!!!”
NON BLOCKING EVENT BASED I/O




$(document).ready(function(){
     alert(“document loaded”);
});
$(“.button”).click(function(){
     alert(“button clicked”);
});
NON BLOCKING EVENT BASED I/O




var http = require('http');
http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Hello Worldn');
}).listen(1337, '127.0.0.1');
console.log('Server running at http://127.0.0.1:1337/');
NON BLOCKING EVENT BASED I/O
NON BLOCKING EVENT BASED I/O
NON BLOCKING EVENT BASED I/O
NON BLOCKING EVENT BASED I/O
USE ASYNCHRONOUS FOR
              COSTLY OPERATION

• Notification.

• Search.

• Stream.

• Logging   via network. eg: Scribe.
LAZY LOAD IMAGES
CLIENT SIDE TEMPLATING
WHY CLIENT SIDE TEMPLATING?


•   Extensible: You can change the template without change the
    logic.

•   Expressive: As expressive as desktop application.

•   Cacheable: Provide our template to the browser once.

•   Bandwidth friendly: Reduce amount of bandwidth usage by
    just providing raw data (JSON) to browser and let browser
    render the dom element.

•   Minifiable.
WHY CLIENT SIDE TEMPLATING?
WHY CLIENT SIDE TEMPLATING?




        jTemplate
             vs
          PURE
             vs
     Closure Template
WHY CLIENT SIDE TEMPLATING?
HOWTO (CLOSURE TEMPLATE):
HOWTO (CLOSURE TEMPLATE):
HOWTO (CLOSURE TEMPLATE):
HOWTO (CLOSURE TEMPLATE):
HOWTO (CLOSURE TEMPLATE):
HOWTO (CLOSURE TEMPLATE):
CLIENT SIDE TEMPLATING IN MINDTALK
CSS CLASS MAPPING
CSS CLASS MAPPING




     BEFORE
CSS CLASS MAPPING




     AFTER
Web Optimization Level: Paranoid
Closure Template
             +
    Closure Stylesheet
             +
     Closure Compiler
             =
Highly Optimized Web App
Mindtalk when using CSS Mapping
THANK YOU
Reference
• http://sixrevisions.com/graphics-design/jpeg-101-a-crash-course-guide-on-
 jpeg/

• http://www.slideshare.net/bonoseo/web-performance-optimization-wpo

• http://nodejs.org/

• http://getcomparisons.com/node-js-vs-php

• http://blog.pandaform.com/techie/browser-side-template-engines-roundup/

• http://www.agafix.org

More Related Content

What's hot (18)

PPTX
Drupal performance optimization Best Practices
Ratnesh kumar, CSM
 
PPT
Configuring Apache Servers for Better Web Perormance
Spark::red
 
PDF
WordCamp RVA
codearachnid_test
 
PPT
Implementing High Performance Drupal Sites
Shri Kumar
 
PDF
Best practices para publicar un WebSite con SharePoint Server 2010
Juan Andrés Valenzuela
 
PDF
Php & web server performace
Tuyển Đoàn
 
PDF
Zingme practice for building scalable website with PHP
Chau Thanh
 
PPTX
Caching 101 - WordCamp OC
Eugene Kovshilovsky
 
PDF
High Performance Drupal
Chapter Three
 
PPT
World Wide Web Caching
ersanbilik
 
PPTX
Understanding Web Cache
ProdigyView
 
PPTX
Level Up: 5 Expert Tips for Optimizing WordPress Performance
Pantheon
 
PPT
Rest services caching
Sperasoft
 
KEY
Performance Tuning - MuraCon 2012
eballisty
 
ODP
Caching Strategies
Michal Špaček
 
PDF
Drupal 7 performance and optimization
Shafqat Hussain
 
PPTX
WordPress Speed Optimization
Dinesh Jain
 
PDF
PAC 2019 virtual Mark Tomlinson
Neotys
 
Drupal performance optimization Best Practices
Ratnesh kumar, CSM
 
Configuring Apache Servers for Better Web Perormance
Spark::red
 
WordCamp RVA
codearachnid_test
 
Implementing High Performance Drupal Sites
Shri Kumar
 
Best practices para publicar un WebSite con SharePoint Server 2010
Juan Andrés Valenzuela
 
Php & web server performace
Tuyển Đoàn
 
Zingme practice for building scalable website with PHP
Chau Thanh
 
Caching 101 - WordCamp OC
Eugene Kovshilovsky
 
High Performance Drupal
Chapter Three
 
World Wide Web Caching
ersanbilik
 
Understanding Web Cache
ProdigyView
 
Level Up: 5 Expert Tips for Optimizing WordPress Performance
Pantheon
 
Rest services caching
Sperasoft
 
Performance Tuning - MuraCon 2012
eballisty
 
Caching Strategies
Michal Špaček
 
Drupal 7 performance and optimization
Shafqat Hussain
 
WordPress Speed Optimization
Dinesh Jain
 
PAC 2019 virtual Mark Tomlinson
Neotys
 

Similar to Web Optimization Level: Paranoid (20)

PDF
Tuning web performance
George Ang
 
PDF
Tuning Web Performance
Eric ShangKuan
 
PDF
Optimizing Your Frontend Performance
Thomas Weinert
 
PDF
Wordpress optimization
Almog Baku
 
PPT
Web Speed And Scalability
Jason Ragsdale
 
PPTX
Web site loading time optimization
Damith Kothalawala
 
PDF
Let's speed it up a bit (AmsterdamPHP)
pascaldevink
 
ODP
Clug 2011 March web server optimisation
grooverdan
 
PDF
Don't make me wait! or Building High-Performance Web Applications
Stoyan Stefanov
 
PDF
Scaling Drupal: Not IF... HOW
Treehouse Agency
 
PDF
Even faster web sites 1st Edition Steve Souders
huapepotts09
 
PPTX
Presentation Tier optimizations
Anup Hariharan Nair
 
PDF
Performance scalability brandonlyon
Digitaria
 
PDF
Improving The Performance of Your Web App
Joe Stump
 
PPTX
Web Performance, Scalability, and Testing Techniques - Boston PHP Meetup
Jonathan Klein
 
PPTX
Optimizing Client-Side Performance
andrew4web
 
PPTX
Building Faster Websites
Craig Walker
 
PDF
Front end performance improvements
Matthew Farina
 
PPTX
BTV PHP - Building Fast Websites
Jonathan Klein
 
PDF
Evolving Archetecture
leo lapworth
 
Tuning web performance
George Ang
 
Tuning Web Performance
Eric ShangKuan
 
Optimizing Your Frontend Performance
Thomas Weinert
 
Wordpress optimization
Almog Baku
 
Web Speed And Scalability
Jason Ragsdale
 
Web site loading time optimization
Damith Kothalawala
 
Let's speed it up a bit (AmsterdamPHP)
pascaldevink
 
Clug 2011 March web server optimisation
grooverdan
 
Don't make me wait! or Building High-Performance Web Applications
Stoyan Stefanov
 
Scaling Drupal: Not IF... HOW
Treehouse Agency
 
Even faster web sites 1st Edition Steve Souders
huapepotts09
 
Presentation Tier optimizations
Anup Hariharan Nair
 
Performance scalability brandonlyon
Digitaria
 
Improving The Performance of Your Web App
Joe Stump
 
Web Performance, Scalability, and Testing Techniques - Boston PHP Meetup
Jonathan Klein
 
Optimizing Client-Side Performance
andrew4web
 
Building Faster Websites
Craig Walker
 
Front end performance improvements
Matthew Farina
 
BTV PHP - Building Fast Websites
Jonathan Klein
 
Evolving Archetecture
leo lapworth
 
Ad

Web Optimization Level: Paranoid

Editor's Notes