This document discusses strategies for scaling PHP and Drupal applications. It recommends using the latest stable version of PHP and disabling unnecessary PHP extensions and modules to improve performance. It also discusses tuning PHP settings like memory limits and caches. For Drupal, it suggests scaling horizontally, focusing on sessions, files, databases and authenticated users. It provides caching, database, and profiling techniques to optimize performance when scaling Drupal applications.
1. Scaling PHP and Drupal
Handrus Nogueira
handrus@taller.net.br
@handrus
Lucas Arruda
lucas@ciandt.com
@lunascarruda
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. 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.
5. Use the latest PHP stable version
Source: https://blog.asmallorange.com/2013/08/php-roadmap-performance/
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. 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
10. 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
11. 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!
17. ● 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
27. 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
29. 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”