O slideshow foi denunciado.
Utilizamos seu perfil e dados de atividades no LinkedIn para personalizar e exibir anúncios mais relevantes. Altere suas preferências de anúncios quando desejar.

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

Apresentação realizada na DrupalCamp SP 2015 por Handrus Nogueira (Taller) e Lucas Arruda (CI&T).

  • Entre para ver os comentários

  • Seja a primeira pessoa a gostar disto

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

  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

×