escalando php e drupal- performance ao infinito e além! - drupal camp sp 2015
TRANSCRIPT
HandrusBased 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!
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.
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-usageSource: http://php.net/manual/en/features.gc.performance-considerations.php
Use the latest PHP stable version
Source: http://www.lornajane.net/posts/2014/php-5-6-benchmarksSource: http://zsuraski.blogspot.com.au/2014/07/benchmarking-phpng.html
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
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!
mod_phpvs.
FastCGIvs.
PHP-FPM
Apachevs.
Nginx
2Read: http://www.prinew.com/mod-php-vs-fastcgi-vs-php-fpm-for-web-server-scripting/
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/
● 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
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
Avoid database specific queries.
Use Drupal`s built-in Database API whenever possible!
Avoid db_query(), always prefer specific functions.
How dependent of your actual environment are you?
timezonepaths connection stringlimits
timeouts
Number of triesAPI Keys
RedisSpecially useful for entities
Memcachefor key/value storageURI -> HTML output, Session data
tmpfs/ramfsfor all filesystem (I/O intensive) based caching like Boost.
Use Drupal’s built-in
Cache API
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”
Drupal Queue API
https://www.drupal.org/project/httprl
https://www.drupal.org/project/httprl
THANKS FOR
BEINGHERE!
Please evaluate this presentation!http://goo.gl/P8ZDfc
(3 questions only)
@lunascarruda
drupal.org/u/larruda
google.com/+LucasArruda
fb.com/lucasnarruda
linkedin.com/in/larruda
github.com/larruda
@handrus
drupal.org/u/handrus
google.com/+HandrusNogueira
fb.com/handrus
linkedin.com/in/handrus
github.com/handrus