drupal performance - dicas e técnicas para levar seu drupal às nuvens
DESCRIPTION
Palestra proferida em 20/04/2013 na DrupalCamp São Paulo 2013.TRANSCRIPT
![Page 1: Drupal Performance - Dicas e técnicas para levar seu Drupal às nuvens](https://reader033.vdocuments.mx/reader033/viewer/2022060119/5590b1fb1a28abf5058b46ff/html5/thumbnails/1.jpg)
Drupal PerformanceDicas e técnicas para levar seu Drupal às nuvens
Drupalcamp São Paulo 2013 by Paulino Michelazzo
![Page 2: Drupal Performance - Dicas e técnicas para levar seu Drupal às nuvens](https://reader033.vdocuments.mx/reader033/viewer/2022060119/5590b1fb1a28abf5058b46ff/html5/thumbnails/2.jpg)
Por quê WPO?web performance optimization
![Page 3: Drupal Performance - Dicas e técnicas para levar seu Drupal às nuvens](https://reader033.vdocuments.mx/reader033/viewer/2022060119/5590b1fb1a28abf5058b46ff/html5/thumbnails/3.jpg)
![Page 4: Drupal Performance - Dicas e técnicas para levar seu Drupal às nuvens](https://reader033.vdocuments.mx/reader033/viewer/2022060119/5590b1fb1a28abf5058b46ff/html5/thumbnails/4.jpg)
43%
57%
3 sec> 3 sec
57% dos visitantes de sites de viagens saem após 3 segundos
25% mobile
![Page 5: Drupal Performance - Dicas e técnicas para levar seu Drupal às nuvens](https://reader033.vdocuments.mx/reader033/viewer/2022060119/5590b1fb1a28abf5058b46ff/html5/thumbnails/5.jpg)
1 segundo é...
- 11%pageviews
- 7%conversões
- 16%satisfação
![Page 6: Drupal Performance - Dicas e técnicas para levar seu Drupal às nuvens](https://reader033.vdocuments.mx/reader033/viewer/2022060119/5590b1fb1a28abf5058b46ff/html5/thumbnails/6.jpg)
1.6 bilhões de dólares em vendas anuais
![Page 7: Drupal Performance - Dicas e técnicas para levar seu Drupal às nuvens](https://reader033.vdocuments.mx/reader033/viewer/2022060119/5590b1fb1a28abf5058b46ff/html5/thumbnails/7.jpg)
25% de acréscimo em pageviews7 a 12% aumento nas vendas50% de redução de hardware
![Page 8: Drupal Performance - Dicas e técnicas para levar seu Drupal às nuvens](https://reader033.vdocuments.mx/reader033/viewer/2022060119/5590b1fb1a28abf5058b46ff/html5/thumbnails/8.jpg)
tempo é dinheiro
![Page 9: Drupal Performance - Dicas e técnicas para levar seu Drupal às nuvens](https://reader033.vdocuments.mx/reader033/viewer/2022060119/5590b1fb1a28abf5058b46ff/html5/thumbnails/9.jpg)
definindo performance
![Page 10: Drupal Performance - Dicas e técnicas para levar seu Drupal às nuvens](https://reader033.vdocuments.mx/reader033/viewer/2022060119/5590b1fb1a28abf5058b46ff/html5/thumbnails/10.jpg)
é lento ou está lento?
![Page 11: Drupal Performance - Dicas e técnicas para levar seu Drupal às nuvens](https://reader033.vdocuments.mx/reader033/viewer/2022060119/5590b1fb1a28abf5058b46ff/html5/thumbnails/11.jpg)
![Page 12: Drupal Performance - Dicas e técnicas para levar seu Drupal às nuvens](https://reader033.vdocuments.mx/reader033/viewer/2022060119/5590b1fb1a28abf5058b46ff/html5/thumbnails/12.jpg)
![Page 13: Drupal Performance - Dicas e técnicas para levar seu Drupal às nuvens](https://reader033.vdocuments.mx/reader033/viewer/2022060119/5590b1fb1a28abf5058b46ff/html5/thumbnails/13.jpg)
O Drupal é lento?
Não!Desenvolvedores e e designers o tornam lento
![Page 14: Drupal Performance - Dicas e técnicas para levar seu Drupal às nuvens](https://reader033.vdocuments.mx/reader033/viewer/2022060119/5590b1fb1a28abf5058b46ff/html5/thumbnails/14.jpg)
1ª regra
definir se o website é lento ou se ele está lento
![Page 15: Drupal Performance - Dicas e técnicas para levar seu Drupal às nuvens](https://reader033.vdocuments.mx/reader033/viewer/2022060119/5590b1fb1a28abf5058b46ff/html5/thumbnails/15.jpg)
o que é lento?
![Page 16: Drupal Performance - Dicas e técnicas para levar seu Drupal às nuvens](https://reader033.vdocuments.mx/reader033/viewer/2022060119/5590b1fb1a28abf5058b46ff/html5/thumbnails/16.jpg)
aquilo que impacta na conversão de usuários
![Page 17: Drupal Performance - Dicas e técnicas para levar seu Drupal às nuvens](https://reader033.vdocuments.mx/reader033/viewer/2022060119/5590b1fb1a28abf5058b46ff/html5/thumbnails/17.jpg)
![Page 18: Drupal Performance - Dicas e técnicas para levar seu Drupal às nuvens](https://reader033.vdocuments.mx/reader033/viewer/2022060119/5590b1fb1a28abf5058b46ff/html5/thumbnails/18.jpg)
14% 86%
backend frontend
10.91.6
Top 300K
![Page 19: Drupal Performance - Dicas e técnicas para levar seu Drupal às nuvens](https://reader033.vdocuments.mx/reader033/viewer/2022060119/5590b1fb1a28abf5058b46ff/html5/thumbnails/19.jpg)
80 a 90% das lesmas estão no
front-end
Mate-as antes
2ª regra
![Page 20: Drupal Performance - Dicas e técnicas para levar seu Drupal às nuvens](https://reader033.vdocuments.mx/reader033/viewer/2022060119/5590b1fb1a28abf5058b46ff/html5/thumbnails/20.jpg)
80 ~ 90% no Drupal
tema
![Page 21: Drupal Performance - Dicas e técnicas para levar seu Drupal às nuvens](https://reader033.vdocuments.mx/reader033/viewer/2022060119/5590b1fb1a28abf5058b46ff/html5/thumbnails/21.jpg)
• Arquivos JavaScript
• Arquivos CSS
• Imagens
• Requisições HTTP
• DNS Lookup’s
![Page 22: Drupal Performance - Dicas e técnicas para levar seu Drupal às nuvens](https://reader033.vdocuments.mx/reader033/viewer/2022060119/5590b1fb1a28abf5058b46ff/html5/thumbnails/22.jpg)
3 arquivos
ativar
1 arquivo
![Page 23: Drupal Performance - Dicas e técnicas para levar seu Drupal às nuvens](https://reader033.vdocuments.mx/reader033/viewer/2022060119/5590b1fb1a28abf5058b46ff/html5/thumbnails/23.jpg)
JavaScript
• Colocá-los no fim do código
• Minificar arquivos
• Carregar arquivos externos assincronamente
• Combinar arquivos
![Page 24: Drupal Performance - Dicas e técnicas para levar seu Drupal às nuvens](https://reader033.vdocuments.mx/reader033/viewer/2022060119/5590b1fb1a28abf5058b46ff/html5/thumbnails/24.jpg)
Carga assíncrona
var script = document.createElement('script'), scripts = document.getElementsByTagName('script')[0];script.async = true;script.src = url;scripts.parentNode.insertBefore(script, scripts);
![Page 25: Drupal Performance - Dicas e técnicas para levar seu Drupal às nuvens](https://reader033.vdocuments.mx/reader033/viewer/2022060119/5590b1fb1a28abf5058b46ff/html5/thumbnails/25.jpg)
FiF - frame in frame(function() { var url = 'http://example.org/js.js'; var iframe = document.createElement('iframe'); (iframe.frameElement || iframe).style.cssText = "width: 0; height: 0; border: 0"; iframe.src = "javascript:false"; var where = document.getElementsByTagName('script')[0]; where.parentNode.insertBefore(iframe, where); var doc = iframe.contentWindow.document; doc.open().write('<body onload="'+ 'var js = document.createElement(\'script\');'+ 'js.src = \''+ url +'\';'+ 'document.body.appendChild(js);">'); doc.close();}());
https://www.facebook.com/note.php?note_id=10151176218703920
![Page 26: Drupal Performance - Dicas e técnicas para levar seu Drupal às nuvens](https://reader033.vdocuments.mx/reader033/viewer/2022060119/5590b1fb1a28abf5058b46ff/html5/thumbnails/26.jpg)
8 arquivos
3 arquivos
ativar
![Page 27: Drupal Performance - Dicas e técnicas para levar seu Drupal às nuvens](https://reader033.vdocuments.mx/reader033/viewer/2022060119/5590b1fb1a28abf5058b46ff/html5/thumbnails/27.jpg)
Apelando...
function hook_css_alter(&$css) { // Remove defaults.css file. unset($css[drupal_get_path('module','system')'/defaults.css']);}
![Page 28: Drupal Performance - Dicas e técnicas para levar seu Drupal às nuvens](https://reader033.vdocuments.mx/reader033/viewer/2022060119/5590b1fb1a28abf5058b46ff/html5/thumbnails/28.jpg)
CSS
• Colocá-los no início do código
• Minificar arquivos
• Fugir de @import
• Combinar arquivos
![Page 29: Drupal Performance - Dicas e técnicas para levar seu Drupal às nuvens](https://reader033.vdocuments.mx/reader033/viewer/2022060119/5590b1fb1a28abf5058b46ff/html5/thumbnails/29.jpg)
98k 25k
73k
Imagens
![Page 30: Drupal Performance - Dicas e técnicas para levar seu Drupal às nuvens](https://reader033.vdocuments.mx/reader033/viewer/2022060119/5590b1fb1a28abf5058b46ff/html5/thumbnails/30.jpg)
53k 1.9k
51.1k
97%
Imagens
![Page 31: Drupal Performance - Dicas e técnicas para levar seu Drupal às nuvens](https://reader033.vdocuments.mx/reader033/viewer/2022060119/5590b1fb1a28abf5058b46ff/html5/thumbnails/31.jpg)
Imagens
• JPG
• Progressivas
• Qualidade
• PNG
• Indexadas
DPI não se usa em monitor!!!
![Page 32: Drupal Performance - Dicas e técnicas para levar seu Drupal às nuvens](https://reader033.vdocuments.mx/reader033/viewer/2022060119/5590b1fb1a28abf5058b46ff/html5/thumbnails/32.jpg)
requisições HTTP
• Não fazer
• Não fazer
• Precisa fazer, reduza
• (menos css, menos js, menos imagens)
![Page 33: Drupal Performance - Dicas e técnicas para levar seu Drupal às nuvens](https://reader033.vdocuments.mx/reader033/viewer/2022060119/5590b1fb1a28abf5058b46ff/html5/thumbnails/33.jpg)
o terror da requisição
404
![Page 34: Drupal Performance - Dicas e técnicas para levar seu Drupal às nuvens](https://reader033.vdocuments.mx/reader033/viewer/2022060119/5590b1fb1a28abf5058b46ff/html5/thumbnails/34.jpg)
DNS Lookup’s
• Reduza
• Reduza
• Precisa mesmo? Traga para mais perto
• perto = dentro
![Page 35: Drupal Performance - Dicas e técnicas para levar seu Drupal às nuvens](https://reader033.vdocuments.mx/reader033/viewer/2022060119/5590b1fb1a28abf5058b46ff/html5/thumbnails/35.jpg)
3ª regra
10 e 20%rede e servidor
difícil, mas não impossível
![Page 36: Drupal Performance - Dicas e técnicas para levar seu Drupal às nuvens](https://reader033.vdocuments.mx/reader033/viewer/2022060119/5590b1fb1a28abf5058b46ff/html5/thumbnails/36.jpg)
tempo para 1º byte
DNS lookup
Conexão inicial
Tempo de espera
![Page 37: Drupal Performance - Dicas e técnicas para levar seu Drupal às nuvens](https://reader033.vdocuments.mx/reader033/viewer/2022060119/5590b1fb1a28abf5058b46ff/html5/thumbnails/37.jpg)
![Page 38: Drupal Performance - Dicas e técnicas para levar seu Drupal às nuvens](https://reader033.vdocuments.mx/reader033/viewer/2022060119/5590b1fb1a28abf5058b46ff/html5/thumbnails/38.jpg)
10 ~ 20% no Drupal
![Page 39: Drupal Performance - Dicas e técnicas para levar seu Drupal às nuvens](https://reader033.vdocuments.mx/reader033/viewer/2022060119/5590b1fb1a28abf5058b46ff/html5/thumbnails/39.jpg)
cache• APC - Alternative PHP Cache
• cache de código PHP
• Memcached
• cache banco e código
• Varnish
• cache não-autenticado
![Page 40: Drupal Performance - Dicas e técnicas para levar seu Drupal às nuvens](https://reader033.vdocuments.mx/reader033/viewer/2022060119/5590b1fb1a28abf5058b46ff/html5/thumbnails/40.jpg)
boost
• Módulo que não depende de terceiros para funcionamento
• Alternativa ao Varnish
![Page 41: Drupal Performance - Dicas e técnicas para levar seu Drupal às nuvens](https://reader033.vdocuments.mx/reader033/viewer/2022060119/5590b1fb1a28abf5058b46ff/html5/thumbnails/41.jpg)
views• views cache
• basta ativar
• views litepager (drupal.org/project/views_litepager)
• remove query COUNT
• não apresenta nº total de páginas
• não permite navegação para última
![Page 42: Drupal Performance - Dicas e técnicas para levar seu Drupal às nuvens](https://reader033.vdocuments.mx/reader033/viewer/2022060119/5590b1fb1a28abf5058b46ff/html5/thumbnails/42.jpg)
cache de blocos
• Reduz o tempo de carga de blocos
• Maravilhoso em conjunto com memcache
![Page 43: Drupal Performance - Dicas e técnicas para levar seu Drupal às nuvens](https://reader033.vdocuments.mx/reader033/viewer/2022060119/5590b1fb1a28abf5058b46ff/html5/thumbnails/43.jpg)
Tips & Tricks
![Page 44: Drupal Performance - Dicas e técnicas para levar seu Drupal às nuvens](https://reader033.vdocuments.mx/reader033/viewer/2022060119/5590b1fb1a28abf5058b46ff/html5/thumbnails/44.jpg)
• realpath_cache_size = 64K (monitore)
• query_cache_size = 128M
• query_cache_limit = 1M
![Page 45: Drupal Performance - Dicas e técnicas para levar seu Drupal às nuvens](https://reader033.vdocuments.mx/reader033/viewer/2022060119/5590b1fb1a28abf5058b46ff/html5/thumbnails/45.jpg)
• Database logging (dblog)
• Statistics
• PHP filter
Corram!!!!!
![Page 46: Drupal Performance - Dicas e técnicas para levar seu Drupal às nuvens](https://reader033.vdocuments.mx/reader033/viewer/2022060119/5590b1fb1a28abf5058b46ff/html5/thumbnails/46.jpg)
Last words
• Otimização é trabalhosa
• mas o resultado vale a pena
• Otimização é experiência
• combinar ingredientes e cenários
![Page 47: Drupal Performance - Dicas e técnicas para levar seu Drupal às nuvens](https://reader033.vdocuments.mx/reader033/viewer/2022060119/5590b1fb1a28abf5058b46ff/html5/thumbnails/47.jpg)
obrigado
Paulino Michelazzo
about.me/pmichelazzo