0
Sander van de Graaf
      IDG Nederland
Web 2.0
Topics
•   Webwereld / Zoom
•   Bottlenecks
    •   PHP
    •   MySQL
    •   Apache
•   Caching
•   Vragen
Webwereld / Zoom
Webwereld
•   4,5 miljoen pageviews per maand




                                      Webwereld / Zoom
                 ...
Webwereld
•   4,5 miljoen pageviews per maand
•   99% dynamisch




                                      Webwereld / Zoom...
Webwereld
•   4,5 miljoen pageviews per maand
•   99% dynamisch
•   Virtualhost




                                      ...
Webwereld
•   4,5 miljoen pageviews per maand
•   99% dynamisch
•   Virtualhost
•   PHP 4




                            ...
Webwereld
•   4,5 miljoen pageviews per maand
•   99% dynamisch
•   Virtualhost
•   PHP 4
•   scripts


                  ...
Webwereld
•   4,5 miljoen pageviews per maand
•   99% dynamisch
•   Virtualhost
•   PHP 4
•   scripts
•   Smarty
         ...
Zoom.nl
•   5+ miljoen pageviews




                           Webwereld / Zoom
                           Bottlenecks
  ...
Zoom.nl
•   5+ miljoen pageviews
•   100% dynamisch




                           Webwereld / Zoom
                      ...
Zoom.nl
•   5+ miljoen pageviews
•   100% dynamisch
•   2 webservers




                           Webwereld / Zoom
     ...
Zoom.nl
•   5+ miljoen pageviews
•   100% dynamisch
•   2 webservers
•   3,8TB data




                           Webwere...
Zoom.nl
•   5+ miljoen pageviews
•   100% dynamisch
•   2 webservers
•   3,8TB data
•   ImageMagick ipv GD


             ...
Zoom.nl
•   5+ miljoen pageviews
•   100% dynamisch
•   2 webservers
•   3,8TB data
•   ImageMagick ipv GD
•   Smarty
    ...
Bottlenecks
Bottlenecks


•   Applicatie
•   Database
•   NAS


                           Webwereld / Zoom
                          ...
PHP
PHP


•   Optimalisaties
•   APD
•   Intermediate Code Caching


                                Webwereld / Zoom
        ...
Optimalisaties

for($foo=0;$foo<count($bar);$foo++)
{
    // do something
}

                                      Webwere...
Optimalisaties

$barCount = count($bar);
for($foo=0;$foo<$barCount;++$foo)
{
    // do something
}

                      ...
APD


PProf




              Webwereld / Zoom
              Bottlenecks
                    PHP
                    MySQL...
APD



apd_set_pprof_trace();

                         Webwereld / Zoom
                         Bottlenecks
            ...
Webwereld / Zoom
Bottlenecks
      PHP
      MySQL
      Apache
Caching
Vragen
Intermediate code caching


 •   eAccelerator
 •   Zend Optimizer
 •   APC


                        Webwereld / Zoom
    ...
MySQL
MySQL


•   Background
•   Optimalisaties



                         Webwereld / Zoom
                         Bottleneck...
Background


•   MySQL 4.1.10
•   2 database servers
•   MyISAM


                          Webwereld / Zoom
             ...
Optimalisaties
•   Valkuilen




                             Webwereld / Zoom
                             Bottlenecks
  ...
ORDER BY RAND()


SELECT * FROM images ORDER BY RAND() LIMIT 10;




                                                 Webw...
ORDER BY RAND()


SELECT * FROM images
WHERE id IN (1243,34234,2341,135465,123,653);




                                 ...
WHERE 1


SELECT * FROM images WHERE 1 ORDER BY id DESC LIMIT 10;




                                                    ...
WHERE 1


SELECT * FROM images ORDER BY id DESC LIMIT 10;




                                                  Webwereld ...
Optimalisaties
•   Valkuilen

•   Indexes




                               Webwereld / Zoom
                            ...
Force Index

SELECT * FROM images FORCE INDEX(user_id)
  WHERE user_id = “12”
  ORDER BY created_on DESC
  LIMIT 10

     ...
Optimalisaties
•   Valkuilen

•   Indexes

•   EXPLAIN




                               Webwereld / Zoom
               ...
EXPLAIN SELECT * FROM images LIMIT 10;




                                         Webwereld / Zoom
                     ...
EXPLAIN SELECT * FROM images LIMIT 10;




                                         Webwereld / Zoom
                     ...
EXPLAIN SELECT I.* FROM images I, zoom_profile.users U
  WHERE I.user_id = U.id
  AND I.user_id = 1244
  LIMIT 10;




    ...
Optimalisaties
•   Valkuilen

•   Indexes

•   EXPLAIN

•   Connection types




                               Webwereld ...
Optimalisaties
•   Valkuilen

•   Indexes

•   EXPLAIN

•   Connection types

•   Table optimalisaties




               ...
Optimalisaties
•   Valkuilen

•   Indexes

•   EXPLAIN

•   Connection types

•   Table optimalisaties

•   PROCESSLIST


...
Optimalisaties
•   Valkuilen

•   Indexes

•   EXPLAIN

•   Connection types

•   Table optimalisaties

•   PROCESSLIST

•...
Optimalisaties
•   Valkuilen

•   Indexes

•   EXPLAIN

•   Connection types

•   Table optimalisaties

•   PROCESSLIST

•...
Optimalisaties
•   Valkuilen

•   Indexes

•   EXPLAIN

•   Connection types

•   Table optimalisaties

•   PROCESSLIST

•...
Apache
Apache


•   Apache 2.0
•   htaccess
•   mod_expires


                           Webwereld / Zoom
                       ...
.htaccess

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} ^.*public_images.*$

RewriteRule ^public_i...
.htaccess

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} ^.*public_images.*$

RewriteRule ^public_i...
mod_expires
<IfModule mod_expires.c>
   ExpiresActive ON
   ExpiresByType image/gif quot;now plus 1 weekquot;
   ExpiresBy...
Caching
Caching
•   (intermediate) Code Caching




                                  Webwereld / Zoom
                           ...
Caching
•   (intermediate) Code Caching
•   Page caching




                                  Webwereld / Zoom
          ...
Caching
•   (intermediate) Code Caching
•   Page caching
•   Fragment caching




                                  Webwer...
Caching
•   (intermediate) Code Caching
•   Page caching
•   Fragment caching
•   Object caching




                     ...
Caching
•   (intermediate) Code Caching
•   Page caching
•   Fragment caching
•   Object caching
•   Content caching


   ...
Vragen?
DPC2007 Case Study Zoom & Webwereld (Sander vd Graaf)
DPC2007 Case Study Zoom & Webwereld (Sander vd Graaf)
DPC2007 Case Study Zoom & Webwereld (Sander vd Graaf)
Upcoming SlideShare
Loading in...5
×

DPC2007 Case Study Zoom & Webwereld (Sander vd Graaf)

1,690

Published on

Dutch PHP Conference 2007

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,690
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
40
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "DPC2007 Case Study Zoom & Webwereld (Sander vd Graaf)"

  1. 1. Sander van de Graaf IDG Nederland
  2. 2. Web 2.0
  3. 3. Topics • Webwereld / Zoom • Bottlenecks • PHP • MySQL • Apache • Caching • Vragen
  4. 4. Webwereld / Zoom
  5. 5. Webwereld • 4,5 miljoen pageviews per maand Webwereld / Zoom Bottlenecks PHP MySQL Apache Caching Vragen
  6. 6. Webwereld • 4,5 miljoen pageviews per maand • 99% dynamisch Webwereld / Zoom Bottlenecks PHP MySQL Apache Caching Vragen
  7. 7. Webwereld • 4,5 miljoen pageviews per maand • 99% dynamisch • Virtualhost Webwereld / Zoom Bottlenecks PHP MySQL Apache Caching Vragen
  8. 8. Webwereld • 4,5 miljoen pageviews per maand • 99% dynamisch • Virtualhost • PHP 4 Webwereld / Zoom Bottlenecks PHP MySQL Apache Caching Vragen
  9. 9. Webwereld • 4,5 miljoen pageviews per maand • 99% dynamisch • Virtualhost • PHP 4 • scripts Webwereld / Zoom Bottlenecks PHP MySQL Apache Caching Vragen
  10. 10. Webwereld • 4,5 miljoen pageviews per maand • 99% dynamisch • Virtualhost • PHP 4 • scripts • Smarty Webwereld / Zoom Bottlenecks PHP MySQL Apache Caching Vragen
  11. 11. Zoom.nl • 5+ miljoen pageviews Webwereld / Zoom Bottlenecks PHP MySQL Apache Caching Vragen
  12. 12. Zoom.nl • 5+ miljoen pageviews • 100% dynamisch Webwereld / Zoom Bottlenecks PHP MySQL Apache Caching Vragen
  13. 13. Zoom.nl • 5+ miljoen pageviews • 100% dynamisch • 2 webservers Webwereld / Zoom Bottlenecks PHP MySQL Apache Caching Vragen
  14. 14. Zoom.nl • 5+ miljoen pageviews • 100% dynamisch • 2 webservers • 3,8TB data Webwereld / Zoom Bottlenecks PHP MySQL Apache Caching Vragen
  15. 15. Zoom.nl • 5+ miljoen pageviews • 100% dynamisch • 2 webservers • 3,8TB data • ImageMagick ipv GD Webwereld / Zoom Bottlenecks PHP MySQL Apache Caching Vragen
  16. 16. Zoom.nl • 5+ miljoen pageviews • 100% dynamisch • 2 webservers • 3,8TB data • ImageMagick ipv GD • Smarty Webwereld / Zoom Bottlenecks PHP MySQL Apache Caching Vragen
  17. 17. Bottlenecks
  18. 18. Bottlenecks • Applicatie • Database • NAS Webwereld / Zoom Bottlenecks PHP MySQL Apache Caching Vragen
  19. 19. PHP
  20. 20. PHP • Optimalisaties • APD • Intermediate Code Caching Webwereld / Zoom Bottlenecks PHP MySQL Apache Caching Vragen
  21. 21. Optimalisaties for($foo=0;$foo<count($bar);$foo++) { // do something } Webwereld / Zoom Bottlenecks PHP MySQL Apache Caching Vragen
  22. 22. Optimalisaties $barCount = count($bar); for($foo=0;$foo<$barCount;++$foo) { // do something } Webwereld / Zoom Bottlenecks PHP MySQL Apache Caching Vragen
  23. 23. APD PProf Webwereld / Zoom Bottlenecks PHP MySQL Apache Caching Vragen
  24. 24. APD apd_set_pprof_trace(); Webwereld / Zoom Bottlenecks PHP MySQL Apache Caching Vragen
  25. 25. Webwereld / Zoom Bottlenecks PHP MySQL Apache Caching Vragen
  26. 26. Intermediate code caching • eAccelerator • Zend Optimizer • APC Webwereld / Zoom Bottlenecks PHP MySQL Apache Caching Vragen
  27. 27. MySQL
  28. 28. MySQL • Background • Optimalisaties Webwereld / Zoom Bottlenecks PHP MySQL Apache Caching Vragen
  29. 29. Background • MySQL 4.1.10 • 2 database servers • MyISAM Webwereld / Zoom Bottlenecks PHP MySQL Apache Caching Vragen
  30. 30. Optimalisaties • Valkuilen Webwereld / Zoom Bottlenecks PHP MySQL Apache Caching Vragen
  31. 31. ORDER BY RAND() SELECT * FROM images ORDER BY RAND() LIMIT 10; Webwereld / Zoom Bottlenecks PHP MySQL Apache Caching Vragen
  32. 32. ORDER BY RAND() SELECT * FROM images WHERE id IN (1243,34234,2341,135465,123,653); Webwereld / Zoom Bottlenecks PHP MySQL Apache Caching Vragen
  33. 33. WHERE 1 SELECT * FROM images WHERE 1 ORDER BY id DESC LIMIT 10; Webwereld / Zoom Bottlenecks PHP MySQL Apache Caching Vragen
  34. 34. WHERE 1 SELECT * FROM images ORDER BY id DESC LIMIT 10; Webwereld / Zoom Bottlenecks PHP MySQL Apache Caching Vragen
  35. 35. Optimalisaties • Valkuilen • Indexes Webwereld / Zoom Bottlenecks PHP MySQL Apache Caching Vragen
  36. 36. Force Index SELECT * FROM images FORCE INDEX(user_id) WHERE user_id = “12” ORDER BY created_on DESC LIMIT 10 Webwereld / Zoom Bottlenecks PHP MySQL Apache Caching Vragen
  37. 37. Optimalisaties • Valkuilen • Indexes • EXPLAIN Webwereld / Zoom Bottlenecks PHP MySQL Apache Caching Vragen
  38. 38. EXPLAIN SELECT * FROM images LIMIT 10; Webwereld / Zoom Bottlenecks PHP MySQL Apache Caching Vragen
  39. 39. EXPLAIN SELECT * FROM images LIMIT 10; Webwereld / Zoom Bottlenecks PHP MySQL Apache Caching Vragen
  40. 40. EXPLAIN SELECT I.* FROM images I, zoom_profile.users U WHERE I.user_id = U.id AND I.user_id = 1244 LIMIT 10; Webwereld / Zoom Bottlenecks PHP MySQL Apache Caching Vragen
  41. 41. Optimalisaties • Valkuilen • Indexes • EXPLAIN • Connection types Webwereld / Zoom Bottlenecks PHP MySQL Apache Caching Vragen
  42. 42. Optimalisaties • Valkuilen • Indexes • EXPLAIN • Connection types • Table optimalisaties Webwereld / Zoom Bottlenecks PHP MySQL Apache Caching Vragen
  43. 43. Optimalisaties • Valkuilen • Indexes • EXPLAIN • Connection types • Table optimalisaties • PROCESSLIST Webwereld / Zoom Bottlenecks PHP MySQL Apache Caching Vragen
  44. 44. Optimalisaties • Valkuilen • Indexes • EXPLAIN • Connection types • Table optimalisaties • PROCESSLIST • MTOP Webwereld / Zoom Bottlenecks PHP MySQL Apache Caching Vragen
  45. 45. Optimalisaties • Valkuilen • Indexes • EXPLAIN • Connection types • Table optimalisaties • PROCESSLIST • MTOP • SLOW Query Log Webwereld / Zoom Bottlenecks PHP MySQL Apache Caching Vragen
  46. 46. Optimalisaties • Valkuilen • Indexes • EXPLAIN • Connection types • Table optimalisaties • PROCESSLIST • MTOP • SLOW Query Log • Webwereld / Zoom De-normalisatie Bottlenecks PHP MySQL Apache Caching Vragen
  47. 47. Apache
  48. 48. Apache • Apache 2.0 • htaccess • mod_expires Webwereld / Zoom Bottlenecks PHP MySQL Apache Caching Vragen
  49. 49. .htaccess RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} ^.*public_images.*$ RewriteRule ^public_images/([0-9]*)/([0-9]*)/(.*)$ /do_some_magic_stuff.php?user_id=$1&width=$2&filename=$ Webwereld / Zoom Bottlenecks PHP MySQL Apache Caching Vragen
  50. 50. .htaccess RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} ^.*public_images.*$ RewriteRule ^public_images/([0-9]*)/([0-9]*)/(.*)$ /do_some_magic_stuff.php?user_id=$1&width=$2&filename=$ Webwereld / Zoom Bottlenecks PHP MySQL Apache Caching Vragen
  51. 51. mod_expires <IfModule mod_expires.c> ExpiresActive ON ExpiresByType image/gif quot;now plus 1 weekquot; ExpiresByType image/png quot;now plus 1 weekquot; ExpiresByType image/jpeg quot;now plus 1 weekquot; ExpiresByType text/css quot;now plus 15 minutequot; ExpiresByType application/x-javascript quot;now plus 15 minquot; ExpiresDefault quot;nowquot; Webwereld / Zoom </IfModule> Bottlenecks PHP MySQL Apache Caching Vragen
  52. 52. Caching
  53. 53. Caching • (intermediate) Code Caching Webwereld / Zoom Bottlenecks PHP MySQL Apache Caching Vragen
  54. 54. Caching • (intermediate) Code Caching • Page caching Webwereld / Zoom Bottlenecks PHP MySQL Apache Caching Vragen
  55. 55. Caching • (intermediate) Code Caching • Page caching • Fragment caching Webwereld / Zoom Bottlenecks PHP MySQL Apache Caching Vragen
  56. 56. Caching • (intermediate) Code Caching • Page caching • Fragment caching • Object caching Webwereld / Zoom Bottlenecks PHP MySQL Apache Caching Vragen
  57. 57. Caching • (intermediate) Code Caching • Page caching • Fragment caching • Object caching • Content caching Webwereld / Zoom Bottlenecks PHP MySQL Apache Caching Vragen
  58. 58. Vragen?
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×