SlideShare ist ein Scribd-Unternehmen logo
1 von 26
Downloaden Sie, um offline zu lesen
Web optimization
                 oàn Văn Tuy n
                   Pentalog Vietnam
http://www.facebook.com/doanvantuyen   doanvantuyen@gmail.com




                                                                1
Gi i thi u chung
• M c đích:
  “Chia s m t s kinh nghi m giúp tăng t c
    đ truy c p vào website”
• Áp d ng:
  “Dành cho nh ng website có lư ng truy
    c p ít và trung bình v i tài nguyên h n
    ch ”


                    PHP DAY 18/12/2010        2
Content
1.   HTTP request flow diagram
2.   Optimizing Page generate
3.   Minimizing round-trip times
4.   Minimizing request / response size
5.   Optimizing brower rendering
6.   Tools for Optimizing


                   PHP DAY 18/12/2010     3
1. HTTP request flow diagram
                                                            DNS server


                                    t
                                u es
                             Req              se
                         S                  on
                        N                 sp                  PHP compile & parser
                       D                re
                                  S
                                DN
Render page
                                        Page HTTP request

                                    Page HTTP response
                                   Image, JS, CSS request

              Client                       Image, JS, CSS                            DB
                                                                Web server



                                                   PHP DAY 18/12/2010                     4
2. Optimizing Page generate

•   Cache
•   Opcode cache
•   Server Configuration
•   Optimize code & log analysis =>
    Xdebug



                  PHP DAY 18/12/2010   5
2.1 Cache
• What:
  – Page cache
  – Block cache
  – Data cache
• How:
  –   Write on file
  –   Memory
  –   Database
  –   Static/Global variable




                               PHP DAY 18/12/2010   6
2.2 Opcode cache
•APC
•PHP accelerator
•eAccelerator
•Alternative PHP
Cache
•ionCube PHP
Accelerator
•XCache
•Zend Accelerator




                    PHP DAY 18/12/2010   7
2.3 Server Configuration
• Apache
  – MPM, remove .htaccess, GZip, ETag, Cache
    control
• PHP
  – Maximum memory, maximum execution time…
• MySQL
  – Slow SQL log




                     PHP DAY 18/12/2010        8
2.4 Optimize code & log
analysis
• Demo XDebug
• Other debug statement
  –   pint_r($x) , print_r($x, true)
  –   var_dump()
  –   thow new Exception()
  –   debug_print_backtrace()
  –   microtime(true)
  –   …



                        PHP DAY 18/12/2010   9
3. Minimizing round-trip
times
•   Use brower’s cache
•   User external CSS & javascript
•   Avoid 404 error
•   Combine CSS & JS file
•   Use CDN (Content delivery network)
•   Parallel download


                  PHP DAY 18/12/2010     10
3.1 Use brower’s cache




            PHP DAY 18/12/2010   11
3.2 User external CSS &
javascript




             PHP DAY 18/12/2010   12
3.3 Avoid 404 error




            PHP DAY 18/12/2010   13
4.4 Combine CSS & JS file

GOOD




BAD




              PHP DAY 18/12/2010   14
4.5 Use CDN




              PHP DAY 18/12/2010   15
3.6 Parallel download




             PHP DAY 18/12/2010   16
4. Minimizing request /
response size
• Use a cookieless domain for static
  content
• Use GZip
• Minify HTML, CSS, Javascript
• Optimize Image (and favicon.ico)



                 PHP DAY 18/12/2010    17
4.1 Use a cookieless domain for static
content




                    PHP DAY 18/12/2010   18
4.2 Use GZip




               PHP DAY 18/12/2010   19
4.3 Minify HTML, CSS, JS




             PHP DAY 18/12/2010   20
4.4 Optimize images
• Do not use BMPs or TIFFs
• Use PNG, GIF for small image or
  simple graphics
• Use JPG for photo
• Reduce the size of image to fit with
  display area
• Use small & cacheable favicon.ico


                 PHP DAY 18/12/2010      21
5. Optimizing brower
   rendering
•       Put CSS on top, javascript on
        bottom
•       Specify image size
•       Post load & Pre load
•       Use smart event handle
    –    Use $(“a”).click(function(){}); thay cho <a href=
         “javascript: …”



                            PHP DAY 18/12/2010               22
6. Tools for Optimizing




           XDebug & WinCacheGrind




            PHP DAY 18/12/2010      23
6. Tools for Optimizing (Cont)




                                https://addons.mozilla.org/en-US/firefox/addon/1843/




http://code.google.com/speed/page-speed/download.html     https://addons.mozilla.org/en-US/firefox/addon/5369/
                                                  PHP DAY 18/12/2010                                      24
Reference
•   http://code.google.com/speed/page-speed/docs/rules_intro.html
•   http://developer.yahoo.com/performance/rules.html
•   http://www.xdebug.org/
•   https://addons.mozilla.org/en-US/firefox/addon/1843/
•   http://developer.yahoo.com/yslow/
•   http://code.google.com/speed/page-speed/
•   http://sourceforge.net/projects/wincachegrind




                                 PHP DAY 18/12/2010                 25
Thanks !




           26

Weitere ähnliche Inhalte

Was ist angesagt?

Less and faster – Cache tips for WordPress developers
Less and faster – Cache tips for WordPress developersLess and faster – Cache tips for WordPress developers
Less and faster – Cache tips for WordPress developersSeravo
 
PHP conference Berlin 2015: running PHP on Nginx
PHP conference Berlin 2015: running PHP on NginxPHP conference Berlin 2015: running PHP on Nginx
PHP conference Berlin 2015: running PHP on NginxHarald Zeitlhofer
 
Caching with Memcached and APC
Caching with Memcached and APCCaching with Memcached and APC
Caching with Memcached and APCBen Ramsey
 
Search in WordPress - how it works and howto customize it
Search in WordPress - how it works and howto customize itSearch in WordPress - how it works and howto customize it
Search in WordPress - how it works and howto customize itOtto Kekäläinen
 
Choosing a Web Architecture for Perl
Choosing a Web Architecture for PerlChoosing a Web Architecture for Perl
Choosing a Web Architecture for PerlPerrin Harkins
 
Memcached Presentation
Memcached PresentationMemcached Presentation
Memcached PresentationAsif Ali
 
Boost your website by running PHP on Nginx
Boost your website by running PHP on NginxBoost your website by running PHP on Nginx
Boost your website by running PHP on NginxHarald Zeitlhofer
 
Performance Tuning - MuraCon 2012
Performance Tuning - MuraCon 2012Performance Tuning - MuraCon 2012
Performance Tuning - MuraCon 2012eballisty
 
Web Performance Optimization with HTTP/3
Web Performance Optimization with HTTP/3Web Performance Optimization with HTTP/3
Web Performance Optimization with HTTP/3SangJin Kang
 
Magento performance & optimisation best practices
Magento performance & optimisation best practicesMagento performance & optimisation best practices
Magento performance & optimisation best practicesPhilippe Humeau
 
Connection Pooling in PostgreSQL using pgbouncer
Connection Pooling in PostgreSQL using pgbouncer Connection Pooling in PostgreSQL using pgbouncer
Connection Pooling in PostgreSQL using pgbouncer Sameer Kumar
 
EasyEngine - Command-Line tool to manage WordPress Sites on Nginx
EasyEngine - Command-Line tool to manage WordPress Sites on NginxEasyEngine - Command-Line tool to manage WordPress Sites on Nginx
EasyEngine - Command-Line tool to manage WordPress Sites on NginxrtCamp
 
From One to a Cluster
From One to a ClusterFrom One to a Cluster
From One to a Clusterguestd34230
 
Engage 2013 - Multi Channel Data Collection
Engage 2013 - Multi Channel Data CollectionEngage 2013 - Multi Channel Data Collection
Engage 2013 - Multi Channel Data CollectionWebtrends
 

Was ist angesagt? (20)

Less and faster – Cache tips for WordPress developers
Less and faster – Cache tips for WordPress developersLess and faster – Cache tips for WordPress developers
Less and faster – Cache tips for WordPress developers
 
PHP conference Berlin 2015: running PHP on Nginx
PHP conference Berlin 2015: running PHP on NginxPHP conference Berlin 2015: running PHP on Nginx
PHP conference Berlin 2015: running PHP on Nginx
 
Running php on nginx
Running php on nginxRunning php on nginx
Running php on nginx
 
Caching with Memcached and APC
Caching with Memcached and APCCaching with Memcached and APC
Caching with Memcached and APC
 
Scaling PHP web apps
Scaling PHP web appsScaling PHP web apps
Scaling PHP web apps
 
Memcache
MemcacheMemcache
Memcache
 
Search in WordPress - how it works and howto customize it
Search in WordPress - how it works and howto customize itSearch in WordPress - how it works and howto customize it
Search in WordPress - how it works and howto customize it
 
Choosing a Web Architecture for Perl
Choosing a Web Architecture for PerlChoosing a Web Architecture for Perl
Choosing a Web Architecture for Perl
 
Memcached Presentation
Memcached PresentationMemcached Presentation
Memcached Presentation
 
Running PHP on Nginx
Running PHP on NginxRunning PHP on Nginx
Running PHP on Nginx
 
Boost your website by running PHP on Nginx
Boost your website by running PHP on NginxBoost your website by running PHP on Nginx
Boost your website by running PHP on Nginx
 
5 things MySql
5 things MySql5 things MySql
5 things MySql
 
Improve Magento Performance
Improve Magento PerformanceImprove Magento Performance
Improve Magento Performance
 
Performance Tuning - MuraCon 2012
Performance Tuning - MuraCon 2012Performance Tuning - MuraCon 2012
Performance Tuning - MuraCon 2012
 
Web Performance Optimization with HTTP/3
Web Performance Optimization with HTTP/3Web Performance Optimization with HTTP/3
Web Performance Optimization with HTTP/3
 
Magento performance & optimisation best practices
Magento performance & optimisation best practicesMagento performance & optimisation best practices
Magento performance & optimisation best practices
 
Connection Pooling in PostgreSQL using pgbouncer
Connection Pooling in PostgreSQL using pgbouncer Connection Pooling in PostgreSQL using pgbouncer
Connection Pooling in PostgreSQL using pgbouncer
 
EasyEngine - Command-Line tool to manage WordPress Sites on Nginx
EasyEngine - Command-Line tool to manage WordPress Sites on NginxEasyEngine - Command-Line tool to manage WordPress Sites on Nginx
EasyEngine - Command-Line tool to manage WordPress Sites on Nginx
 
From One to a Cluster
From One to a ClusterFrom One to a Cluster
From One to a Cluster
 
Engage 2013 - Multi Channel Data Collection
Engage 2013 - Multi Channel Data CollectionEngage 2013 - Multi Channel Data Collection
Engage 2013 - Multi Channel Data Collection
 

Andere mochten auch

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 PHPVõ Duy Tuấn
 
Speed up with hiphop php 2014 01-22
Speed up with hiphop php 2014 01-22Speed up with hiphop php 2014 01-22
Speed up with hiphop php 2014 01-22Võ Duy Tuấn
 
Caching strategy and apc
Caching strategy and apcCaching strategy and apc
Caching strategy and apcVõ Duy Tuấn
 
Heavy Web Optimization: Backend
Heavy Web Optimization: BackendHeavy Web Optimization: Backend
Heavy Web Optimization: BackendVõ Duy Tuấn
 
Heavy Web Optimization: Frontend
Heavy Web Optimization: FrontendHeavy Web Optimization: Frontend
Heavy Web Optimization: FrontendVõ Duy Tuấn
 
Scale with Microservices
Scale with MicroservicesScale with Microservices
Scale with MicroservicesVõ Duy Tuấn
 
How to Build Recommender System with Content based Filtering
How to Build Recommender System with Content based FilteringHow to Build Recommender System with Content based Filtering
How to Build Recommender System with Content based FilteringVõ Duy Tuấn
 
Chatbot in Sale Management
Chatbot in Sale ManagementChatbot in Sale Management
Chatbot in Sale ManagementVõ Duy Tuấn
 
Building a Recommendation Engine - An example of a product recommendation engine
Building a Recommendation Engine - An example of a product recommendation engineBuilding a Recommendation Engine - An example of a product recommendation engine
Building a Recommendation Engine - An example of a product recommendation engineNYC Predictive Analytics
 
Recommender system algorithm and architecture
Recommender system algorithm and architectureRecommender system algorithm and architecture
Recommender system algorithm and architectureLiang Xiang
 

Andere mochten auch (11)

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
 
Speed up with hiphop php 2014 01-22
Speed up with hiphop php 2014 01-22Speed up with hiphop php 2014 01-22
Speed up with hiphop php 2014 01-22
 
Caching strategy and apc
Caching strategy and apcCaching strategy and apc
Caching strategy and apc
 
Heavy Web Optimization: Backend
Heavy Web Optimization: BackendHeavy Web Optimization: Backend
Heavy Web Optimization: Backend
 
React introduction
React introductionReact introduction
React introduction
 
Heavy Web Optimization: Frontend
Heavy Web Optimization: FrontendHeavy Web Optimization: Frontend
Heavy Web Optimization: Frontend
 
Scale with Microservices
Scale with MicroservicesScale with Microservices
Scale with Microservices
 
How to Build Recommender System with Content based Filtering
How to Build Recommender System with Content based FilteringHow to Build Recommender System with Content based Filtering
How to Build Recommender System with Content based Filtering
 
Chatbot in Sale Management
Chatbot in Sale ManagementChatbot in Sale Management
Chatbot in Sale Management
 
Building a Recommendation Engine - An example of a product recommendation engine
Building a Recommendation Engine - An example of a product recommendation engineBuilding a Recommendation Engine - An example of a product recommendation engine
Building a Recommendation Engine - An example of a product recommendation engine
 
Recommender system algorithm and architecture
Recommender system algorithm and architectureRecommender system algorithm and architecture
Recommender system algorithm and architecture
 

Ähnlich wie Web optimization

Type URL, Enter, and Then …
Type URL, Enter, and Then …Type URL, Enter, and Then …
Type URL, Enter, and Then …Jinglun Li
 
Optimizing Your Frontend Performance
Optimizing Your Frontend PerformanceOptimizing Your Frontend Performance
Optimizing Your Frontend PerformanceThomas Weinert
 
High performance website
High performance websiteHigh performance website
High performance websiteChamnap Chhorn
 
Optimising Web Application Frontend
Optimising Web Application FrontendOptimising Web Application Frontend
Optimising Web Application Frontendtkramar
 
Static resource-optimization using webutilities
Static resource-optimization using webutilitiesStatic resource-optimization using webutilities
Static resource-optimization using webutilitiesrpatil82
 
High Performance Ajax Applications
High Performance Ajax ApplicationsHigh Performance Ajax Applications
High Performance Ajax ApplicationsSiarhei Barysiuk
 
PAC 2019 virtual Mark Tomlinson
PAC 2019 virtual Mark TomlinsonPAC 2019 virtual Mark Tomlinson
PAC 2019 virtual Mark TomlinsonNeotys
 
WordPress Speed & Performance from Pagely's CTO
WordPress Speed & Performance from Pagely's CTOWordPress Speed & Performance from Pagely's CTO
WordPress Speed & Performance from Pagely's CTOLizzie Kardon
 
3 Hacks to Improve WordPress Performance
3 Hacks to Improve WordPress Performance3 Hacks to Improve WordPress Performance
3 Hacks to Improve WordPress PerformanceRF Studio
 
Web performance optimization for modern web applications
Web performance optimization for modern web applicationsWeb performance optimization for modern web applications
Web performance optimization for modern web applicationsChris Love
 
hbaseconasia2017: Building online HBase cluster of Zhihu based on Kubernetes
hbaseconasia2017: Building online HBase cluster of Zhihu based on Kuberneteshbaseconasia2017: Building online HBase cluster of Zhihu based on Kubernetes
hbaseconasia2017: Building online HBase cluster of Zhihu based on KubernetesHBaseCon
 
Pagespeed what, why, and how it works
Pagespeed   what, why, and how it worksPagespeed   what, why, and how it works
Pagespeed what, why, and how it worksIlya Grigorik
 
10 things you can do to speed up your web app today stir trek edition
10 things you can do to speed up your web app today   stir trek edition10 things you can do to speed up your web app today   stir trek edition
10 things you can do to speed up your web app today stir trek editionChris Love
 
Optimization of modern web applications
Optimization of modern web applicationsOptimization of modern web applications
Optimization of modern web applicationsEugene Lazutkin
 
SharePoint Saturday San Antonio: SharePoint 2010 Performance
SharePoint Saturday San Antonio: SharePoint 2010 PerformanceSharePoint Saturday San Antonio: SharePoint 2010 Performance
SharePoint Saturday San Antonio: SharePoint 2010 PerformanceBrian Culver
 
10 Things You Can Do to Speed Up Your Web App Today
10 Things You Can Do to Speed Up Your Web App Today10 Things You Can Do to Speed Up Your Web App Today
10 Things You Can Do to Speed Up Your Web App TodayChris Love
 

Ähnlich wie Web optimization (20)

Type URL, Enter, and Then …
Type URL, Enter, and Then …Type URL, Enter, and Then …
Type URL, Enter, and Then …
 
performance.ppt
performance.pptperformance.ppt
performance.ppt
 
Optimizing Your Frontend Performance
Optimizing Your Frontend PerformanceOptimizing Your Frontend Performance
Optimizing Your Frontend Performance
 
Speed!
Speed!Speed!
Speed!
 
High performance website
High performance websiteHigh performance website
High performance website
 
Optimising Web Application Frontend
Optimising Web Application FrontendOptimising Web Application Frontend
Optimising Web Application Frontend
 
Making the web faster
Making the web fasterMaking the web faster
Making the web faster
 
Static resource-optimization using webutilities
Static resource-optimization using webutilitiesStatic resource-optimization using webutilities
Static resource-optimization using webutilities
 
High Performance Ajax Applications
High Performance Ajax ApplicationsHigh Performance Ajax Applications
High Performance Ajax Applications
 
PAC 2019 virtual Mark Tomlinson
PAC 2019 virtual Mark TomlinsonPAC 2019 virtual Mark Tomlinson
PAC 2019 virtual Mark Tomlinson
 
WordPress Speed & Performance from Pagely's CTO
WordPress Speed & Performance from Pagely's CTOWordPress Speed & Performance from Pagely's CTO
WordPress Speed & Performance from Pagely's CTO
 
3 Hacks to Improve WordPress Performance
3 Hacks to Improve WordPress Performance3 Hacks to Improve WordPress Performance
3 Hacks to Improve WordPress Performance
 
Web performance optimization for modern web applications
Web performance optimization for modern web applicationsWeb performance optimization for modern web applications
Web performance optimization for modern web applications
 
hbaseconasia2017: Building online HBase cluster of Zhihu based on Kubernetes
hbaseconasia2017: Building online HBase cluster of Zhihu based on Kuberneteshbaseconasia2017: Building online HBase cluster of Zhihu based on Kubernetes
hbaseconasia2017: Building online HBase cluster of Zhihu based on Kubernetes
 
Pagespeed what, why, and how it works
Pagespeed   what, why, and how it worksPagespeed   what, why, and how it works
Pagespeed what, why, and how it works
 
Advanced Drupal 8 Caching
Advanced Drupal 8 CachingAdvanced Drupal 8 Caching
Advanced Drupal 8 Caching
 
10 things you can do to speed up your web app today stir trek edition
10 things you can do to speed up your web app today   stir trek edition10 things you can do to speed up your web app today   stir trek edition
10 things you can do to speed up your web app today stir trek edition
 
Optimization of modern web applications
Optimization of modern web applicationsOptimization of modern web applications
Optimization of modern web applications
 
SharePoint Saturday San Antonio: SharePoint 2010 Performance
SharePoint Saturday San Antonio: SharePoint 2010 PerformanceSharePoint Saturday San Antonio: SharePoint 2010 Performance
SharePoint Saturday San Antonio: SharePoint 2010 Performance
 
10 Things You Can Do to Speed Up Your Web App Today
10 Things You Can Do to Speed Up Your Web App Today10 Things You Can Do to Speed Up Your Web App Today
10 Things You Can Do to Speed Up Your Web App Today
 

Mehr von Võ Duy Tuấn

Log management system for Microservices
Log management system for MicroservicesLog management system for Microservices
Log management system for MicroservicesVõ Duy Tuấn
 
Multi-tenant Database Design for SaaS
Multi-tenant Database Design for SaaSMulti-tenant Database Design for SaaS
Multi-tenant Database Design for SaaSVõ Duy Tuấn
 
Mobile outsourcing best practices
Mobile outsourcing best practicesMobile outsourcing best practices
Mobile outsourcing best practicesVõ Duy Tuấn
 
Microservices and docker
Microservices and dockerMicroservices and docker
Microservices and dockerVõ Duy Tuấn
 
Microservices in production
Microservices in productionMicroservices in production
Microservices in productionVõ Duy Tuấn
 
Business Intelligence in Retail Industry
Business Intelligence in Retail IndustryBusiness Intelligence in Retail Industry
Business Intelligence in Retail IndustryVõ Duy Tuấn
 
Php psr standard 2014 01-22
Php psr standard 2014 01-22Php psr standard 2014 01-22
Php psr standard 2014 01-22Võ Duy Tuấn
 
How to build a Recommender System
How to build a Recommender SystemHow to build a Recommender System
How to build a Recommender SystemVõ Duy Tuấn
 
Reader.vn 2012 - The Book Of Life
Reader.vn 2012 - The Book Of LifeReader.vn 2012 - The Book Of Life
Reader.vn 2012 - The Book Of LifeVõ Duy Tuấn
 
PHP: Debugger, Profiler and more
PHP: Debugger, Profiler and morePHP: Debugger, Profiler and more
PHP: Debugger, Profiler and moreVõ Duy Tuấn
 
Magento overview and how sell Magento extensions
Magento overview and how sell Magento extensionsMagento overview and how sell Magento extensions
Magento overview and how sell Magento extensionsVõ Duy Tuấn
 
Javascript unit testing framework
Javascript unit testing frameworkJavascript unit testing framework
Javascript unit testing frameworkVõ Duy Tuấn
 
Html5, css3 and the future of web technologies
Html5, css3 and the future of web technologiesHtml5, css3 and the future of web technologies
Html5, css3 and the future of web technologiesVõ Duy Tuấn
 
How startups can benefit from launch community
How startups can benefit from launch communityHow startups can benefit from launch community
How startups can benefit from launch communityVõ Duy Tuấn
 
Build your own PHP extension
Build your own PHP extensionBuild your own PHP extension
Build your own PHP extensionVõ Duy Tuấn
 
Xây dựng mạng xã hội bằng drupal
Xây dựng mạng xã hội bằng drupalXây dựng mạng xã hội bằng drupal
Xây dựng mạng xã hội bằng drupalVõ Duy Tuấn
 
Speed up zing me – ntvv2 code with PHP extension module
Speed up zing me – ntvv2 code with PHP extension moduleSpeed up zing me – ntvv2 code with PHP extension module
Speed up zing me – ntvv2 code with PHP extension moduleVõ Duy Tuấn
 
Hanoi php day 2010 program
Hanoi php day 2010   programHanoi php day 2010   program
Hanoi php day 2010 programVõ Duy Tuấn
 

Mehr von Võ Duy Tuấn (20)

Log management system for Microservices
Log management system for MicroservicesLog management system for Microservices
Log management system for Microservices
 
Multi-tenant Database Design for SaaS
Multi-tenant Database Design for SaaSMulti-tenant Database Design for SaaS
Multi-tenant Database Design for SaaS
 
Flutter introduction
Flutter introductionFlutter introduction
Flutter introduction
 
Mobile outsourcing best practices
Mobile outsourcing best practicesMobile outsourcing best practices
Mobile outsourcing best practices
 
Microservices and docker
Microservices and dockerMicroservices and docker
Microservices and docker
 
Microservices in production
Microservices in productionMicroservices in production
Microservices in production
 
Business Intelligence in Retail Industry
Business Intelligence in Retail IndustryBusiness Intelligence in Retail Industry
Business Intelligence in Retail Industry
 
Php psr standard 2014 01-22
Php psr standard 2014 01-22Php psr standard 2014 01-22
Php psr standard 2014 01-22
 
How to build a Recommender System
How to build a Recommender SystemHow to build a Recommender System
How to build a Recommender System
 
Mobile for web
Mobile for webMobile for web
Mobile for web
 
Reader.vn 2012 - The Book Of Life
Reader.vn 2012 - The Book Of LifeReader.vn 2012 - The Book Of Life
Reader.vn 2012 - The Book Of Life
 
PHP: Debugger, Profiler and more
PHP: Debugger, Profiler and morePHP: Debugger, Profiler and more
PHP: Debugger, Profiler and more
 
Magento overview and how sell Magento extensions
Magento overview and how sell Magento extensionsMagento overview and how sell Magento extensions
Magento overview and how sell Magento extensions
 
Javascript unit testing framework
Javascript unit testing frameworkJavascript unit testing framework
Javascript unit testing framework
 
Html5, css3 and the future of web technologies
Html5, css3 and the future of web technologiesHtml5, css3 and the future of web technologies
Html5, css3 and the future of web technologies
 
How startups can benefit from launch community
How startups can benefit from launch communityHow startups can benefit from launch community
How startups can benefit from launch community
 
Build your own PHP extension
Build your own PHP extensionBuild your own PHP extension
Build your own PHP extension
 
Xây dựng mạng xã hội bằng drupal
Xây dựng mạng xã hội bằng drupalXây dựng mạng xã hội bằng drupal
Xây dựng mạng xã hội bằng drupal
 
Speed up zing me – ntvv2 code with PHP extension module
Speed up zing me – ntvv2 code with PHP extension moduleSpeed up zing me – ntvv2 code with PHP extension module
Speed up zing me – ntvv2 code with PHP extension module
 
Hanoi php day 2010 program
Hanoi php day 2010   programHanoi php day 2010   program
Hanoi php day 2010 program
 

Web optimization

  • 1. Web optimization oàn Văn Tuy n Pentalog Vietnam http://www.facebook.com/doanvantuyen doanvantuyen@gmail.com 1
  • 2. Gi i thi u chung • M c đích: “Chia s m t s kinh nghi m giúp tăng t c đ truy c p vào website” • Áp d ng: “Dành cho nh ng website có lư ng truy c p ít và trung bình v i tài nguyên h n ch ” PHP DAY 18/12/2010 2
  • 3. Content 1. HTTP request flow diagram 2. Optimizing Page generate 3. Minimizing round-trip times 4. Minimizing request / response size 5. Optimizing brower rendering 6. Tools for Optimizing PHP DAY 18/12/2010 3
  • 4. 1. HTTP request flow diagram DNS server t u es Req se S on N sp PHP compile & parser D re S DN Render page Page HTTP request Page HTTP response Image, JS, CSS request Client Image, JS, CSS DB Web server PHP DAY 18/12/2010 4
  • 5. 2. Optimizing Page generate • Cache • Opcode cache • Server Configuration • Optimize code & log analysis => Xdebug PHP DAY 18/12/2010 5
  • 6. 2.1 Cache • What: – Page cache – Block cache – Data cache • How: – Write on file – Memory – Database – Static/Global variable PHP DAY 18/12/2010 6
  • 7. 2.2 Opcode cache •APC •PHP accelerator •eAccelerator •Alternative PHP Cache •ionCube PHP Accelerator •XCache •Zend Accelerator PHP DAY 18/12/2010 7
  • 8. 2.3 Server Configuration • Apache – MPM, remove .htaccess, GZip, ETag, Cache control • PHP – Maximum memory, maximum execution time… • MySQL – Slow SQL log PHP DAY 18/12/2010 8
  • 9. 2.4 Optimize code & log analysis • Demo XDebug • Other debug statement – pint_r($x) , print_r($x, true) – var_dump() – thow new Exception() – debug_print_backtrace() – microtime(true) – … PHP DAY 18/12/2010 9
  • 10. 3. Minimizing round-trip times • Use brower’s cache • User external CSS & javascript • Avoid 404 error • Combine CSS & JS file • Use CDN (Content delivery network) • Parallel download PHP DAY 18/12/2010 10
  • 11. 3.1 Use brower’s cache PHP DAY 18/12/2010 11
  • 12. 3.2 User external CSS & javascript PHP DAY 18/12/2010 12
  • 13. 3.3 Avoid 404 error PHP DAY 18/12/2010 13
  • 14. 4.4 Combine CSS & JS file GOOD BAD PHP DAY 18/12/2010 14
  • 15. 4.5 Use CDN PHP DAY 18/12/2010 15
  • 16. 3.6 Parallel download PHP DAY 18/12/2010 16
  • 17. 4. Minimizing request / response size • Use a cookieless domain for static content • Use GZip • Minify HTML, CSS, Javascript • Optimize Image (and favicon.ico) PHP DAY 18/12/2010 17
  • 18. 4.1 Use a cookieless domain for static content PHP DAY 18/12/2010 18
  • 19. 4.2 Use GZip PHP DAY 18/12/2010 19
  • 20. 4.3 Minify HTML, CSS, JS PHP DAY 18/12/2010 20
  • 21. 4.4 Optimize images • Do not use BMPs or TIFFs • Use PNG, GIF for small image or simple graphics • Use JPG for photo • Reduce the size of image to fit with display area • Use small & cacheable favicon.ico PHP DAY 18/12/2010 21
  • 22. 5. Optimizing brower rendering • Put CSS on top, javascript on bottom • Specify image size • Post load & Pre load • Use smart event handle – Use $(“a”).click(function(){}); thay cho <a href= “javascript: …” PHP DAY 18/12/2010 22
  • 23. 6. Tools for Optimizing XDebug & WinCacheGrind PHP DAY 18/12/2010 23
  • 24. 6. Tools for Optimizing (Cont) https://addons.mozilla.org/en-US/firefox/addon/1843/ http://code.google.com/speed/page-speed/download.html https://addons.mozilla.org/en-US/firefox/addon/5369/ PHP DAY 18/12/2010 24
  • 25. Reference • http://code.google.com/speed/page-speed/docs/rules_intro.html • http://developer.yahoo.com/performance/rules.html • http://www.xdebug.org/ • https://addons.mozilla.org/en-US/firefox/addon/1843/ • http://developer.yahoo.com/yslow/ • http://code.google.com/speed/page-speed/ • http://sourceforge.net/projects/wincachegrind PHP DAY 18/12/2010 25
  • 26. Thanks ! 26