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.
2. Lucas Arruda
Based on Campinas-SP
Software Architect @ CI&T
Open-Source enthusiast
~10 yrs on the road
Zend Certified Engineer PHP 5.3
Google Cloud Platform Qualified Dev.
Drupaler for 4 yrs
3. Handrus
Based on Bauru-SP/Florianópolis-SC
Software Architect / Dev @ Taller
Open-Source and Agile
~10 yrs on the road
Drupaler for 3 yrs
7. 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!
8. 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. Does your app use
session data?
No: you’re good to go!
Yes: then you’ll need to
manage this data across
multiple servers.
18. Sharing session data
Fault tolerant
No bottleneck
Cheaper
buut… it needs architecure changes!
PHP Session
Management
Persistent load balancing
Sharing session data
Persistent load balacing
Single point of failure
Bottleneck
Expensive
19. Options
Shared file-system
Database
Memcache / Redis
Sharing
session data
session.name
session.save_handler
session.save_path
Handlers
files
user
memcache
20. Avoid database specific
queries.
Good libraries can help
(Doctrine FTW!)
If not possible
Document like any
Technical Debt!
21. And choose well
your database!!
● MySQL
● MariaDB
● PerconaDB
Version?!
22.
23. paths timezone connection string
limits
timeouts
API Keys Number of tries
How dependent of your actual
environment are you?