Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Scaling PHP and Drupal
Handrus Nogueira
handrus@taller.net.br
@handrus
Lucas Arruda
lucas@ciandt.com
@lunascarruda
Handrus
Based on Florianópolis-SC / BR
Software Architect / Dev @ Taller
Web & Open-Source & Agile
~11 yrs on the road
Dru...
Lucas Arruda
Software Architect @ CI&T DCO
Open-Source enthusiast
Acquia Certified Developer
Based on Campinas-SP / Brazil...
The Basics
Use the latest PHP stable version
Source: https://blog.asmallorange.com/2013/08/php-roadmap-performance/
Use the latest PHP stable version
Source: https://www.lourdas.name/blog/php-53-vs-54-vs-55-speed-and-memory-usage
Source: ...
Use the latest PHP stable version
Source: http://www.lornajane.net/posts/2014/php-5-6-benchmarks
Source: http://zsuraski.b...
Source: https://kinsta.com/blog/hhvm-vs-php-7/
Disable unnecessary PHP extensions and web-server modules
● PHP extensions consume memory heap
● Some badly written can ca...
Fine tune your php.ini!
● memory_limit
memory_get_usage() / memory_get_peak_usage()
● realpath_cache_size
realpath_cache_g...
mod_php
vs.
FastCGI
vs.
PHP-FPM
Apache
vs.
Nginx
2Read: http://www.prinew.com/mod-php-vs-fastcgi-vs-php-fpm-for-web-server...
PHP ACCELERATORS
Alternative PHP Cache (APC)
Zend OPcache
XCache
apc.shm_size
apc.ttl
apc.num_files_hint
apc.gc_ttl
apc.max_file_size
apc.stat
APC
2Read: https://www.scalingphpbook.com/be...
● Is PHP really your bottleneck?
● Same memory, less CPU
● Great for authenticated users.
● Some problems with NGINX (solv...
Scaling Drupal
Horizontally
(“Cattles, not Pets”)
Points of Attention
● Session
● Files
● Database
● Authenticated Users
Authenticated Users
- AuthCache contrib module
- Memcache
- AJAX
Database
- MySQL Read Replicas
+ AutoSlave contrib module...
Avoid database specific
queries.
Use Drupal`s built-in
Database API whenever
possible!
Avoid db_query(),
always prefer spe...
And choose well
your database!!
● MySQL
● MariaDB
● PerconaDB
Version?!
How dependent of your actual
environment are you?
timezonepaths connection string
limits
timeouts
Number of triesAPI Keys
Caching Mechanisms
Redis
Specially useful for entities
Memcache
for key/value storage
URI -> HTML output, Session data
tmpfs/ramfs
for all fi...
Reverse proxy caching
Nginx Varnish
Some modules that
break reverse caching
Adaptive Image - Since it detects browser to serve
image the reverse proxy will ca...
Drupal Queue
API
Helpful Modules
RULES!
:-D
https://www.drupal.org/project/httprl
https://www.drupal.org/project/httprl
Profiling is about Measuring!
XHProf
Q&A
ciandt.com
Presentation Deck
http://goo.gl/0cV1KT
THANKS
FOR
BEING
HERE!
Please evaluate this presentation!
http://goo.gl/P8ZDfc
(3 questions only)
@lunascarruda
drupal.org/u/larruda
lunascar@gmail.com
google.com/+LucasArruda
fb.com/lucasnarruda
linkedin.com/in/larruda
...
Escalando PHP e Drupal: performance ao infinito e além! - DrupalCamp SP 2015
Escalando PHP e Drupal: performance ao infinito e além! - DrupalCamp SP 2015
Escalando PHP e Drupal: performance ao infinito e além! - DrupalCamp SP 2015
Escalando PHP e Drupal: performance ao infinito e além! - DrupalCamp SP 2015
Escalando PHP e Drupal: performance ao infinito e além! - DrupalCamp SP 2015
Escalando PHP e Drupal: performance ao infinito e além! - DrupalCamp SP 2015
Escalando PHP e Drupal: performance ao infinito e além! - DrupalCamp SP 2015
Escalando PHP e Drupal: performance ao infinito e além! - DrupalCamp SP 2015
Upcoming SlideShare
Loading in …5
×

Escalando PHP e Drupal: performance ao infinito e além! - DrupalCamp SP 2015

577 views

Published on

Esta apresentação é dividida em duas partes: a primeira aborda aspectos de performance em relação ao ambiente no qual seu Drupal estará rodando. Iremos passar por questões básicas como versões de software, ajustes de configuração, aceleradores e caching de bytecode até assuntos mais avançados como boas práticas de desenvolvimento que permitem que sua aplicação Drupal escale e portanto seja possível implantá-la na nuvem. Uma vez lá, como podemos tirar proveito deste ambiente volátil para aumentar ainda mais a performance e escalabilidade de maneira horizontal. A segunda parte trata sobre questões específicas de Drupal, como tuning de banco de dados, mecanismos de caching (memcache, varnish, Akamai, etc), cuidados com consumo de memória e tratamento de arquivos estáticos. Você sairá com um checklist gigantesco que irá lhe garantir bons momentos de alegria ao "tunar" sua aplicação Drupal ;-)

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Escalando PHP e Drupal: performance ao infinito e além! - DrupalCamp SP 2015

  1. 1. Scaling PHP and Drupal Handrus Nogueira handrus@taller.net.br @handrus Lucas Arruda lucas@ciandt.com @lunascarruda
  2. 2. Handrus Based on Florianópolis-SC / BR Software Architect / Dev @ Taller Web & Open-Source & Agile ~11 yrs on the road Drupaler for ~7 yrs Dev with Passion!
  3. 3. Lucas Arruda Software Architect @ CI&T DCO Open-Source enthusiast Acquia Certified Developer Based on Campinas-SP / Brazil Zend Certified Engineer PHP 5.3 Drupaler for 4+ yrs GCP Authorized Trainer & Qualified Dev.
  4. 4. The Basics
  5. 5. Use the latest PHP stable version Source: https://blog.asmallorange.com/2013/08/php-roadmap-performance/
  6. 6. Use the latest PHP stable version Source: https://www.lourdas.name/blog/php-53-vs-54-vs-55-speed-and-memory-usage Source: http://php.net/manual/en/features.gc.performance-considerations.php
  7. 7. Use the latest PHP stable version Source: http://www.lornajane.net/posts/2014/php-5-6-benchmarks Source: http://zsuraski.blogspot.com.au/2014/07/benchmarking-phpng.html
  8. 8. Source: https://kinsta.com/blog/hhvm-vs-php-7/
  9. 9. Disable unnecessary PHP extensions and web-server modules ● PHP extensions consume memory heap ● Some badly written can cause memory leaks ● The same applies for web-server modules ● Disable if you don’t need them! 2Read: http://www.slideshare.net/jpauli/help-im-leaking-memory-in-php
  10. 10. Fine tune your php.ini! ● memory_limit memory_get_usage() / memory_get_peak_usage() ● realpath_cache_size realpath_cache_get() ● realpath_cache_ttl Max execution per thread - will affect memory usage!
  11. 11. mod_php vs. FastCGI vs. PHP-FPM Apache vs. Nginx 2Read: http://www.prinew.com/mod-php-vs-fastcgi-vs-php-fpm-for-web-server-scripting/
  12. 12. PHP ACCELERATORS
  13. 13. Alternative PHP Cache (APC) Zend OPcache XCache
  14. 14. apc.shm_size apc.ttl apc.num_files_hint apc.gc_ttl apc.max_file_size apc.stat APC 2Read: https://www.scalingphpbook.com/best-zend-opcache-settings-tuning-config/
  15. 15. ● Is PHP really your bottleneck? ● Same memory, less CPU ● Great for authenticated users. ● Some problems with NGINX (solvable!) ● Great resume: http://alexrayu.com/blog/drupal-hhvm
  16. 16. Scaling Drupal Horizontally (“Cattles, not Pets”)
  17. 17. Points of Attention ● Session ● Files ● Database ● Authenticated Users
  18. 18. Authenticated Users - AuthCache contrib module - Memcache - AJAX Database - MySQL Read Replicas + AutoSlave contrib module + Orbital Cache Nuke (OCN) Files - Rsync bi-directional replication - NFS shared mount - Cloud-based solution (S3/GCS) Session - Drupal handes it beautifully - Session is stored on Database - Memcache to cache tables
  19. 19. Avoid database specific queries. Use Drupal`s built-in Database API whenever possible! Avoid db_query(), always prefer specific functions.
  20. 20. And choose well your database!! ● MySQL ● MariaDB ● PerconaDB Version?!
  21. 21. How dependent of your actual environment are you? timezonepaths connection string limits timeouts Number of triesAPI Keys
  22. 22. Caching Mechanisms
  23. 23. Redis Specially useful for entities Memcache for key/value storage URI -> HTML output, Session data tmpfs/ramfs for all filesystem (I/O intensive) based caching like Boost. Use Drupal’s built-in Cache API
  24. 24. Reverse proxy caching Nginx Varnish
  25. 25. Some modules that break reverse caching Adaptive Image - Since it detects browser to serve image the reverse proxy will cache the first occurence. Text Size - Use cookies to store user choosen size. Recaptcha - Use cookie to store valid challenge. Key phrases: “Depends on cookies” “Browser detection”
  26. 26. Drupal Queue API
  27. 27. Helpful Modules
  28. 28. RULES! :-D
  29. 29. https://www.drupal.org/project/httprl
  30. 30. https://www.drupal.org/project/httprl
  31. 31. Profiling is about Measuring! XHProf
  32. 32. Q&A ciandt.com Presentation Deck http://goo.gl/0cV1KT
  33. 33. THANKS FOR BEING HERE! Please evaluate this presentation! http://goo.gl/P8ZDfc (3 questions only)
  34. 34. @lunascarruda drupal.org/u/larruda lunascar@gmail.com google.com/+LucasArruda fb.com/lucasnarruda linkedin.com/in/larruda github.com/larruda @handrus drupal.org/u/handrus handrus@gmail.com google.com/+HandrusNogueira fb.com/handrus linkedin.com/in/handrus github.com/handrus

×