PHP site optimization can improve performance by 10-15% through techniques like using Nginx + APC + caching + Memcache + CDN. Database performance is key and can be optimized through simplifying queries, optimization, replication and sharding. Network latency issues can be identified through slow page responses and CPU usage, and addressed through techniques like persistent connections and reducing the number of hops. IO contention and high CPU utilization should also be addressed.
3. Performance or Scalability. Both?
Hiphop (Facebook implementation of php) is high
performing but not scalable
4. Workload distribution of a page
request
10% web server
40% php processing
50% database response
10-15% improvement easily achievable using a
commonly used alternative stack i.e. Nginx +
APC + Htmlcaching + Memcache + CDN
6. Network Latency
How to identify?
When both page response and CPU usage are
slow
Reasons?
DNS Reverse Lookups, TCP Handshakes, High
number of hops
Tools?
Tcpdump, ping, traceroute ..
13. ORM options
Active Record (made popular by Ruby on Rails)
Data Mapper
Collection
Doctrine
Data access methods used by Yii, CI,
Symphony ...
14. Active Record (AR)
It is an object-relational mapping and object-
persistence pattern
It binds a business object with a relational record
(row)
AR class maps to a db table (or view)
AR instance maps to a db table record
AR instance properties maps to db table record
fields
Instance methods act on a specific record
18. Preg
Stripos is 2 times faster than preg
ctype_alnum is 5 times faster than preg
Casting “if ($var == (int) $var)” is 5 times faster
than preg_match(“/^d*$/”, $var)
19. Magic methods
__get, __set, __call
Used by Soap, data tables, java objects
Use sparingly and avoid too much recursion
21. Queue
Queueing is offloading long running tasks to
queuing system
Job Queue
Gearman
Message Queue
ActiveMQ
AWS Simple Queue Service
22. What not to do
Caching should be the last thing to do. (Focus on
performance optimization)
Avoid LIKE queries. (Try Solr, Zend_Lucene)
23. What to do
Minimize require_once. Use autoloader
Horizontal architecture is better than vertical
ex. wide inheritance is better than deep level
inheritance
Lazy loading / Load on Demand
Use diagnostic tools
Zend studio profiler, Code Tracing