Upload
lucas-arruda
View
146
Download
0
Embed Size (px)
DESCRIPTION
Tips and hits on how to scale your PHP application, from tuning your php.ini settings and using accelerators till going through caching mechanisms, reverse proxying and infrastructure setups.
Citation preview
Lucas Arruda
Software Architect @ CI&T
Open-Source enthusiast
~10 yrs on the road
Based on Campinas-SP
Zend Certified Engineer PHP 5.3
Drupaler for 4 yrs
Google Cloud Platform Qualified Dev.
Handrus
Software Architect / Dev @ Taller
Open-Source and Agile
~10 yrs on the road
Based on Bauru-SP/Florianópolis-SC
Drupaler for 3 yrs
The Basics
Use the latest PHP stable version
Use the latest PHP stable version
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!
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
ob_flush()flush()
?
PHP ACCELERATORS
Alternative PHP Cache (APC)
Zend OPcache
XCache
APC OPcache XCache
Zephir
Scaling PHPHorizontally
Does your app use session data?
No: you’re good to go!
Yes: then you’ll need to manage this data across multiple servers.
Sharing session data
Fault tolerantNo bottleneckCheaper
buut… it needs architecure changes!
Persistent load balancing
Sharing session data
PHP Session Management
Persistent load balacing
Single point of failureBottleneckExpensive
Options
Shared file-systemDatabaseMemcache / Redis
session.name
session.save_handler
session.save_path
Sharing session data
Handlers
filesusermemcache
Avoid database specific queries.
Good libraries can help (Doctrine FTW!)
If not possible Document like any Technical Debt!
And choose wellyour database!!
● MySQL● MariaDB● PerconaDB
Version?!
How dependent of your actual environment are you?
timezonepaths connection stringlimits
timeouts
Number of triesAPI Keys
Caching Mechanisms
APCfor caching user data
Memcachefor key/value storage (URI/HTML?)
tmpfs/ramfsfor all file-based caching
Reverse proxying
Nginx Varnish
Q&Aciandt.com
THANKS FOR
BEINGHERE!
Please evaluate this presentation!http://goo.gl/P8ZDfc
(3 questions only)
@lunascarruda
google.com/+LucasArruda
fb.com/lucasnarruda
linkedin.com/in/larruda
github.com/larruda
coderbits.com/larruda
@handrus
google.com/+HandrusNogueira
fb.com/handrus
linkedin.com/in/handrus
github.com/handrus
coderbits.com/handrus