Your SlideShare is downloading. ×
Drupal Camp Kiev 2012 - High Performance Drupal Web Sites
Upcoming SlideShare
Loading in...5

Thanks for flagging this SlideShare!

Oops! An error has occurred.


Saving this for later?

Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime - even offline.

Text the download link to your phone

Standard text messaging rates apply

Drupal Camp Kiev 2012 - High Performance Drupal Web Sites


Published on

Published in: Technology

  • Be the first to comment

No Downloads
Total Views
On Slideshare
From Embeds
Number of Embeds
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

No notes for slide


  • 1. High PerformanceDrupal Web Sites 360°
  • 2. Whos that punk ?!● A French nerd !● Used to manage complex IT projects for the last 10 years● And many more nights on performances issues ... :)● ... who just created his own company
  • 3. Summary Cache Upload & Download Browser rendering Compression Drupal pages architecture Analyze
  • 4. CacheWhat should we cache ? EVERY POSSIBLE THING !!!● PHP (opcode)● Computations (functions results)● Datas (views, DB requests)● Entities & Fields (nodes, comments, taxonomy terms, user profiles,…)● Images (imagecache/styles)● HTML (page, block, panel, pane, views)● Any static ressource (CSS, JS, SWF, SVG, PDF, ZIP, Video, Sound, …)
  • 5. CacheHow should we cache ?PHP (opcode) : // allocate one segment of 32Mb apc.shm_segments=1 apc.shm_size=32 // do not check if php file was updated apc.stat= 0● APC // never expire apc.ttl = 0● Eaccelerator (a bit faster, // use kernel anonymous memory seg fault) apc.mmap_file_mask = /dev/zero.
  • 6. CacheHow should we cache ? function mymodule_complex_calculation_crazy_cache() {Computations (functions results) : static $cache ; if (isset($cache)) { return $cache ; }● drupal_static (sometime static if big if ($cache = &drupal_static(__FUNCTION__)) { return $cache; amount of calls within a page load) } if ($cache = cache_get(my_cache_item, my_cache_bin)) { $cache = $cache->data; }● cache_set / cache_get (use your own else { bin if lot of data to store and/or need // some = complex_calculation(); kitten $cache heavy calculations that kills more control over your cache) cache_set(my_cache_item, $cache, my_cache_bin); } return $cache ; }
  • 7. Cache Note :How should we cache ? A custom cache bin require, at module install, to create a new cache table using the same schema as core cache tables (see table below). Copy/paste from :Datas (views, DB requests) : includes/system.install● Views cache Field Type Null cid varchar(255) no● Views per user cache data longblob yes● Own cache bin for DB requests (if expire int no somehow there is a good reason created int no to request DB directly) headers text yes serialized smallint no
  • 8. CacheHow should we cache ?Entities (nodes, comments, taxonomy terms, user profiles,…) : Entity cache Load 1 000 users● Entity cache 50 45 40 35 First load 30 Next loads seconds 25 20 15 10 5 0 No entity cache Entity cache
  • 9. CacheHow should we cache ?Images (imagecache/styles) :● ImageCache● ImageCache External
  • 10. CacheHow should we cache ?HTML (page, block, panel, pane, views) :● Panels Page Cache● Panels Hash Cache● Varnish● Varnish ESI
  • 11. CacheHow should we cache ?Any static ressource (CSS, JS, SWF, SVG, PDF, ZIP, Video, Sound, …) :● Varnish● Nginx● CDN far-future
  • 12. CacheWhat cache backends ?
  • 13. CacheWhat about cache invalidation ?● Cache actions● Cachetags● Views content cache● Expire● Entity cache flusher
  • 14. Upload & DownloadCookie free domainsCDN module in order to use static resources dedicated domain(s) which differ from main domain (for instance,$cookie_domain have to be set to main domain in settings.php (for instance
  • 15. Upload & DownloadAggregates● JS (Advanced aggregate) Note :● CSS (Advanced aggregate) Sprites are now obselete, use CSS embeded image instead● Images & CSS (CSS (for IE, images <32Kb can be embeded image) embeded)● Images (spritesheets)
  • 16. Upload & DownloadParrallelization● CDN (URL sharding)● Head.js CSS● Yepnopejs(Interesting but not yet drupal integrated) JS
  • 17. Browser renderingJS● Rendering sequence : request as soon as it parse ● JS in footer scope● Head.js / lab.js (defer)
  • 18. Browser renderingCSS● Translate3D, no DOM position change● Pay attention to selectors performances ! No CSS3 selectors (great but slow)● Avoid blinking > no JS to hide an element on load, hide by CSS and show from JS (perception matters!)
  • 19. CompressionWhat should we compress ?● Images● CSS● JS● HTML● «Any» static file
  • 20. CompressionHow should we compress ?Images● Imageapi optimize ● jpegtran ● advpng
  • 21. CompressionHow should we compress ?CSS● Advagg CSS compress● CSS Compressor ● faster than CSSTidy● gzip
  • 22. CompressionHow should we compress ?JS● Advagg JS compress● JSMin ● faster than JSMin+● Gzip
  • 23. CompressionHow should we compress ?HTML● Gzip
  • 24. CompressionHow should we compress ?Any static files● Gzip
  • 25. Drupal pages architectureHow to build a performant page ? USE AS FEW MODULES AS POSSIBLE ! ●Search_api (solr, mongo) ●Panels ●Mongodb ●Panels everywhere ●Redis ●Views ●Memcache ●Rules ●Elysia cron ●Entities
  • 26. Drupal pages architectureWhy homogeneity maters ? Blocks, panes, pick one !One single way of managing « blocks » helps using ESI caching for instance; it also makes easier the cache invalidation management for these «blocks». Keep it simple : one API to implement
  • 27. AnalyzeBrowser level●● Yslow● Firebug● Chrome / Safari developer tools●
  • 28. AnalyzeDrupal level● Devel● Watchdog (redirected to syslog if needed on live server)
  • 29. AnalyzePHP level● FirePHP / ChromePHP● Xhprof (eventually in addition to Xdebug)● PHP error log● PHP-FPM slow logs● MySQL Slow query logs
  • 30. AnalyzeSystem level● strace● tcpdump & wireshark
  • 31. Spasibo bolshoe !Your time now, any question ? Wanna get these slides ? Search for jbguerraz on Slideshare ;)