drupal camp kiev 2012 - high performance drupal web sites

Download Drupal Camp Kiev 2012 - High Performance Drupal Web Sites

If you can't read please download the document

Upload: jbguerraz

Post on 22-Jun-2015

2.670 views

Category:

Technology


0 download

TRANSCRIPT

2. Whos that punk ?!A French nerd ! Used to manage complex IT projects for thelast 10 yearsAnd many more nights on performancesissues ... :)... who just created his own company 3. SummaryCacheUpload & DownloadBrowser renderingCompressionDrupal pages architectureAnalyze 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, ) [email protected] 5. CacheHow should we cache ?PHP (opcode) :// allocate one segment of 32Mbapc.shm_segments=1apc.shm_size=32// do not check if php file was updatedapc.stat= 0APC // never expireapc.ttl = 0Eaccelerator (a bit faster, // use kernel anonymous memoryseg fault)apc.mmap_file_mask = /dev/[email protected] 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 bigif ($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 $cacheheavy calculations that killsmore control over your cache)cache_set(my_cache_item, $cache, my_cache_bin); } return $cache ; } [email protected] 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.installViews cacheFieldTypeNull cid varchar(255) noViews per user cache datalongblob yesOwn cache bin for DB requests (ifexpireintnosomehow there is a good reason created intnoto request DB directly)headers text yes serialized smallintno [email protected] 8. CacheHow should we cache ?Entities (nodes, comments, taxonomy terms, user profiles,) : Entity cache Load 1 000 usersEntity cache50454035 First load30 Next loadsseconds25201510 5 0 No entity cacheEntity cache [email protected] 9. CacheHow should we cache ?Images (imagecache/styles) :ImageCacheImageCache [email protected] 10. CacheHow should we cache ?HTML (page, block, panel, pane, views) :Panels Page CachePanels Hash CacheVarnishVarnish [email protected] 11. CacheHow should we cache ?Any static ressource (CSS, JS, SWF, SVG, PDF, ZIP, Video, Sound, ) :VarnishNginxCDN far-future [email protected] 12. CacheWhat cache backends ? http://janezurevc.name/static/[email protected] 13. CacheWhat about cache invalidation ?Cache actionsCachetagsViews content cacheExpireEntity cache flusher [email protected] 14. Upload & DownloadCookie free domainsCDN module in order to use static resources dedicated domain(s) which differ from main domain (for instance, static.mysite.com)$cookie_domain have to be set to main domain insettings.php (for instance www.mysite.com) [email protected] 15. Upload & DownloadAggregatesJS (Advanced aggregate)Note :CSS (Advanced aggregate)Sprites are now obselete, use CSSembeded image insteadImages & CSS (CSS(for IE, images no JS to hide an element onload, hide by CSS and show from JS(perception matters!)[email protected] 19. CompressionWhat should we compress ?ImagesCSSJSHTMLAny static file [email protected] 20. CompressionHow should we compress ?ImagesImageapi optimize jpegtran [email protected] 21. CompressionHow should we compress ?CSSAdvagg CSS compressCSS Compressor faster than CSSTidygzip [email protected] 22. CompressionHow should we compress ?JSAdvagg JS compressJSMin faster than [email protected] 23. CompressionHow should we compress [email protected] 24. CompressionHow should we compress ?Any static [email protected] 25. Drupal pages architectureHow to build a performant page ?USE AS FEW MODULES AS POSSIBLE !Search_api (solr, mongo)PanelsMongodb Panels everywhereRedis ViewsMemcacheRulesElysia cron [email protected] 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 [email protected] 27. AnalyzeBrowser levelGtmetrix.comYslowFirebugChrome / Safari developer [email protected] 28. AnalyzeDrupal levelDevelWatchdog (redirected to syslog if needed on liveserver)[email protected] 29. AnalyzePHP levelFirePHP / ChromePHPXhprof (eventually in addition to Xdebug)PHP error logPHP-FPM slow logsMySQL Slow query [email protected] 30. AnalyzeSystem levelstracetcpdump & wireshark [email protected] 31. Spasibo bolshoe !Your time now, any question ? Wanna get these slides ?Search for jbguerraz on Slideshare ;)[email protected]