SlideShare une entreprise Scribd logo
1  sur  24
© All rights reserved. Zend Technologies, Inc.
High performance PHP: How
do I make it go faster?
Maurice Kherlakian
Professional Services Consultant
maurice.k@zend.com
© All rights reserved. Zend Technologies, Inc.2
Agenda
• What we will be covering
 The network, database, and application aspects in optimization
 Tools and techniques that assist in optimization (Code tracing, profiling)
 OS level optimizations and tools
 Best practices in application development for an optimized application
 Server clustering
 DEMO
© All rights reserved. Zend Technologies, Inc.3
The network
•Entry point into your system
•Needs to be secured
Firewall
Layer separation: External – DMZ - internal
•Unless you have one server, need to find a traffic
distribution mechanism – Load balancers
Different kinds of load balancers: hardware v/s software
Hardware appliances are costly but robust, do layer 7 lb
Software alternatives are cheaper, do a good job also
• HAProxy
• Ldirectord
• Nginx, Apache with balancer modules
© All rights reserved. Zend Technologies, Inc.4
The network
•Reverse proxy
Avoid having application servers in an externally accessible
environment
Can also be used to load balance
Apache, nginx, lighttpd
Usually reverse proxy connect to backend servers
© All rights reserved. Zend Technologies, Inc.5
The web server
•Different alternatives – choose based on performance
Apache – mod_php
Nginx, lighty with php-fcgi or php-fpm
Windows IIS – FastCGI
•Zend Server
Apache-based, on Linux, Windows, IBM i
Zend engine
© All rights reserved. Zend Technologies, Inc.6
Web servers clustering
•1st step towards scaling solution
After moving the database to a separate server
Configuration syncing: rsync, rmp/deb, svn
Application code deployment
ZSCM
© All rights reserved. Zend Technologies, Inc.7
Deployment strategies
•SVN as a deployment tool
•RPM/deb
•PEAR
•Zend Server .zpk
•More info: watch deployment strategies webinar
(http://www.zend.com/en/resources/webinars/php)
•Check out Shahar’s Best practices in deploying PHP apps
© All rights reserved. Zend Technologies, Inc.8
Web servers session clustering
•What is session clustering
•Failing over to other servers
•Mechanisms for session clustering
Memcached
Lightweight key/value server
Database
Zend Server SC
© All rights reserved. Zend Technologies, Inc.9
Opcode caching
•What is it, why virtually every PHP site uses it
•Drastic effects of code tracing
(Screenshot next slide)
•Different opcode caches
APC, eaccelerator, xcache
Zend Server Optimizer+
•Extra performance boost – check timestamp
© All rights reserved. Zend Technologies, Inc.10
strace with and without O+ activated
•10 times less system calls with O+ active
© All rights reserved. Zend Technologies, Inc.11
Static content
•Why should we separate static/dynamic content
•Techniques for content separation
CDN
Separate sub-domains
Reverse proxying with rules for static content
© All rights reserved. Zend Technologies, Inc.12
Handling large files
•Why large files should not be served from PHP
•Serve large files from a lightweight web server
Lighty, nginx
•Securing large files download
Modules for web servers – authentication logic, then offload to
web server. Usually through headers
Zend Download server
© All rights reserved. Zend Technologies, Inc.13
•To achieve an optimal cluster, many different packages
•What if one solution existed that could do all this?
•Zend server
Optimizer + for code caching
Full page caching
ZSCM for server sync
Code tracing/monitoring for app monitoring
Zend Download server
© All rights reserved. Zend Technologies, Inc.14
Linux
(rpm/web repositories)
IBM i
(PTF)
Windows
(MSI)
Application
Performance
Acceleration
Optimization
Caching
Reliability &
Management
Monitoring
Root-Cause
Configuration
Scale-Out
Clustering
Job Queue
Downloads
Business-grade
PHP
Hot Fixes
Support
Java Bridge
Zend Framework
PHP
Zend Server
ZendStudio(Eclipse-based)
CollaborateDebugProfileTest
Zend Server1
© All rights reserved. Zend Technologies, Inc.15
Database scaling
•Scaling techniques
Replication
Functional separation
Sharding
•Schemaless databases eg: MongoDB
•For analytics, consider a column-oriented database like
Infobright
© All rights reserved. Zend Technologies, Inc.16
Database results caching
•Shared memory (APC)
•Distributed caching (memcached)
•Zend Server data cache
•But all of that doesn’t matter if your application is not
optimized!
© All rights reserved. Zend Technologies, Inc.17
The application
•No cookbook for good application design
•Don’t optimize in early development, risk over-optimization
•Frameworks
Frameworks can make you fall in over-architecting trap
Possible mistakes using DBAL or ORM – like lazy joins
End up making a lot more queries than necessary
© All rights reserved. Zend Technologies, Inc.18
The application
•Write application for what it is intended to be used
•(ex: file processing: load entire file v/s one line at a time:
first approach works well for a few queries, but under high
load 2nd approach better)
© All rights reserved. Zend Technologies, Inc.19
The secrets to application optimization
•Using the right tools
Xdebug
Zend Server Code tracing (demo)
Profiling (demo)
•Monitor execution time and memory usage
•Design intelligently
•Know the hardware you’re writing for and how it operates.
The more you know about it, the better your app will be
© All rights reserved. Zend Technologies, Inc.20
Database optimizations
•Statements tuning
•Tables indexing
•Monitor all queries to DB
Use profiling tools, if using DBAL usually provides one
ZF provides Zend_Db_Profiler that allows logging of queries to
later study them (demo)
Zend_Db_Profiler_Firebug: cool tool that allows displaying all
queries on Firebug. Completely independent from page itself, no
interference with JSON or XML requests
•Use Explain, tune criteria, avoid lazy joins
© All rights reserved. Zend Technologies, Inc.21
How do we fix problems
•Found a bottleneck, how do we fix it?
Rewrite logic to be less demanding, or more demanding, but get
to endpoint faster
•Caching
File caching
Shared mem caching
Distributed (memcached)
•Adding caching should be easy on a well architected app
Domain model
•Caching in most cases is NOT a silver bullet.
© All rights reserved. Zend Technologies, Inc.22
High server loads
•App is optimized, traffic growing, servers start to cough…
•Where is the problem?
•Your application can be cpu-bound, io-bound or memory
bound. So how do you find out?
Use tools like top, vmstat, iostat
•Why is this important?
© All rights reserved. Zend Technologies, Inc.23
Recap
•Be smart!
•Look at the problem, understand it, and solve it.
•Using var_dump is NOT the solution, neither is shooting in
the dark
•Use the right toolset
•Wealth of resources (white papers/webinars…) on zend.com
© All rights reserved. Zend Technologies, Inc.
Thank you!
Maurice Kherlakian
maurice.k@zend.com
http://framework.zend.com
http://www.zend.com

Contenu connexe

Tendances

Ibm spectrum scale fundamentals workshop for americas part 6 spectrumscale el...
Ibm spectrum scale fundamentals workshop for americas part 6 spectrumscale el...Ibm spectrum scale fundamentals workshop for americas part 6 spectrumscale el...
Ibm spectrum scale fundamentals workshop for americas part 6 spectrumscale el...xKinAnx
 
Security of Oracle EBS - How I can Protect my System (UKOUG APPS 18 edition)
Security of Oracle EBS - How I can Protect my System (UKOUG APPS 18 edition)Security of Oracle EBS - How I can Protect my System (UKOUG APPS 18 edition)
Security of Oracle EBS - How I can Protect my System (UKOUG APPS 18 edition)Andrejs Prokopjevs
 
Planning For Catastrophe with IBM WAS and IBM BPM
Planning For Catastrophe with IBM WAS and IBM BPMPlanning For Catastrophe with IBM WAS and IBM BPM
Planning For Catastrophe with IBM WAS and IBM BPMWASdev Community
 
Xen App Platinum For Service Providers (072209)
Xen App Platinum For Service Providers (072209)Xen App Platinum For Service Providers (072209)
Xen App Platinum For Service Providers (072209)Scott Swanburg
 
Scalable High-Availability Session Storage with ZSCM
Scalable High-Availability Session Storage with ZSCMScalable High-Availability Session Storage with ZSCM
Scalable High-Availability Session Storage with ZSCMZend by Rogue Wave Software
 
Top 10 Tricks and Tools of an Oracle EPM Administrator
Top 10 Tricks and Tools of an Oracle EPM AdministratorTop 10 Tricks and Tools of an Oracle EPM Administrator
Top 10 Tricks and Tools of an Oracle EPM Administratornking821
 
W23 - Advanced Performance Tactics for WebSphere Performance
W23 - Advanced Performance Tactics for WebSphere PerformanceW23 - Advanced Performance Tactics for WebSphere Performance
W23 - Advanced Performance Tactics for WebSphere PerformanceHendrik van Run
 
PHP Installed on IBM i - the Nickel Tour
PHP Installed on IBM i - the Nickel TourPHP Installed on IBM i - the Nickel Tour
PHP Installed on IBM i - the Nickel TourRod Flohr
 
Co je nového v XenDesktop 7.6 a XenApp 7.6
Co je nového v XenDesktop 7.6 a XenApp 7.6 Co je nového v XenDesktop 7.6 a XenApp 7.6
Co je nového v XenDesktop 7.6 a XenApp 7.6 MarketingArrowECS_CZ
 
Cloud computing Fundamentals - behind the hood of cloud platforms
Cloud computing Fundamentals - behind the hood of cloud platformsCloud computing Fundamentals - behind the hood of cloud platforms
Cloud computing Fundamentals - behind the hood of cloud platformshnandy
 
VMworld Europe 2014: Virtualizing Databases Doing IT Right – The Sequel
VMworld Europe 2014: Virtualizing Databases Doing IT Right – The SequelVMworld Europe 2014: Virtualizing Databases Doing IT Right – The Sequel
VMworld Europe 2014: Virtualizing Databases Doing IT Right – The SequelVMworld
 
VMworld Europe 2014: Virtual SAN Architecture Deep Dive
VMworld Europe 2014: Virtual SAN Architecture Deep DiveVMworld Europe 2014: Virtual SAN Architecture Deep Dive
VMworld Europe 2014: Virtual SAN Architecture Deep DiveVMworld
 
VMworld Europe 204: Technical Deep Dive on EVO: RAIL, the new VMware Hyper-Co...
VMworld Europe 204: Technical Deep Dive on EVO: RAIL, the new VMware Hyper-Co...VMworld Europe 204: Technical Deep Dive on EVO: RAIL, the new VMware Hyper-Co...
VMworld Europe 204: Technical Deep Dive on EVO: RAIL, the new VMware Hyper-Co...VMworld
 
URP? Excuse You! The Three Kafka Metrics You Need to Know
URP? Excuse You! The Three Kafka Metrics You Need to KnowURP? Excuse You! The Three Kafka Metrics You Need to Know
URP? Excuse You! The Three Kafka Metrics You Need to KnowTodd Palino
 
VMworld Europe 2014: A Blueprint for Disaster Recovery of Business Critical A...
VMworld Europe 2014: A Blueprint for Disaster Recovery of Business Critical A...VMworld Europe 2014: A Blueprint for Disaster Recovery of Business Critical A...
VMworld Europe 2014: A Blueprint for Disaster Recovery of Business Critical A...VMworld
 
VMworld Europe 2014: A DevOps Story - Unlocking the Power of Docker with the ...
VMworld Europe 2014: A DevOps Story - Unlocking the Power of Docker with the ...VMworld Europe 2014: A DevOps Story - Unlocking the Power of Docker with the ...
VMworld Europe 2014: A DevOps Story - Unlocking the Power of Docker with the ...VMworld
 
BP103 - Got Problems? Let's Do a Health Check
BP103 - Got Problems? Let's Do a Health CheckBP103 - Got Problems? Let's Do a Health Check
BP103 - Got Problems? Let's Do a Health CheckLuis Guirigay
 
Got Problems? Let's Do a Health Check
Got Problems? Let's Do a Health CheckGot Problems? Let's Do a Health Check
Got Problems? Let's Do a Health CheckLuis Guirigay
 

Tendances (20)

Ibm spectrum scale fundamentals workshop for americas part 6 spectrumscale el...
Ibm spectrum scale fundamentals workshop for americas part 6 spectrumscale el...Ibm spectrum scale fundamentals workshop for americas part 6 spectrumscale el...
Ibm spectrum scale fundamentals workshop for americas part 6 spectrumscale el...
 
Security of Oracle EBS - How I can Protect my System (UKOUG APPS 18 edition)
Security of Oracle EBS - How I can Protect my System (UKOUG APPS 18 edition)Security of Oracle EBS - How I can Protect my System (UKOUG APPS 18 edition)
Security of Oracle EBS - How I can Protect my System (UKOUG APPS 18 edition)
 
Planning For Catastrophe with IBM WAS and IBM BPM
Planning For Catastrophe with IBM WAS and IBM BPMPlanning For Catastrophe with IBM WAS and IBM BPM
Planning For Catastrophe with IBM WAS and IBM BPM
 
Xen App Platinum For Service Providers (072209)
Xen App Platinum For Service Providers (072209)Xen App Platinum For Service Providers (072209)
Xen App Platinum For Service Providers (072209)
 
Scalable High-Availability Session Storage with ZSCM
Scalable High-Availability Session Storage with ZSCMScalable High-Availability Session Storage with ZSCM
Scalable High-Availability Session Storage with ZSCM
 
Top 10 Tricks and Tools of an Oracle EPM Administrator
Top 10 Tricks and Tools of an Oracle EPM AdministratorTop 10 Tricks and Tools of an Oracle EPM Administrator
Top 10 Tricks and Tools of an Oracle EPM Administrator
 
TechTalkThai-CiscoHyperFlex
TechTalkThai-CiscoHyperFlexTechTalkThai-CiscoHyperFlex
TechTalkThai-CiscoHyperFlex
 
TechTalkThai webinar SAP HANA
TechTalkThai webinar SAP HANATechTalkThai webinar SAP HANA
TechTalkThai webinar SAP HANA
 
W23 - Advanced Performance Tactics for WebSphere Performance
W23 - Advanced Performance Tactics for WebSphere PerformanceW23 - Advanced Performance Tactics for WebSphere Performance
W23 - Advanced Performance Tactics for WebSphere Performance
 
PHP Installed on IBM i - the Nickel Tour
PHP Installed on IBM i - the Nickel TourPHP Installed on IBM i - the Nickel Tour
PHP Installed on IBM i - the Nickel Tour
 
Co je nového v XenDesktop 7.6 a XenApp 7.6
Co je nového v XenDesktop 7.6 a XenApp 7.6 Co je nového v XenDesktop 7.6 a XenApp 7.6
Co je nového v XenDesktop 7.6 a XenApp 7.6
 
Cloud computing Fundamentals - behind the hood of cloud platforms
Cloud computing Fundamentals - behind the hood of cloud platformsCloud computing Fundamentals - behind the hood of cloud platforms
Cloud computing Fundamentals - behind the hood of cloud platforms
 
VMworld Europe 2014: Virtualizing Databases Doing IT Right – The Sequel
VMworld Europe 2014: Virtualizing Databases Doing IT Right – The SequelVMworld Europe 2014: Virtualizing Databases Doing IT Right – The Sequel
VMworld Europe 2014: Virtualizing Databases Doing IT Right – The Sequel
 
VMworld Europe 2014: Virtual SAN Architecture Deep Dive
VMworld Europe 2014: Virtual SAN Architecture Deep DiveVMworld Europe 2014: Virtual SAN Architecture Deep Dive
VMworld Europe 2014: Virtual SAN Architecture Deep Dive
 
VMworld Europe 204: Technical Deep Dive on EVO: RAIL, the new VMware Hyper-Co...
VMworld Europe 204: Technical Deep Dive on EVO: RAIL, the new VMware Hyper-Co...VMworld Europe 204: Technical Deep Dive on EVO: RAIL, the new VMware Hyper-Co...
VMworld Europe 204: Technical Deep Dive on EVO: RAIL, the new VMware Hyper-Co...
 
URP? Excuse You! The Three Kafka Metrics You Need to Know
URP? Excuse You! The Three Kafka Metrics You Need to KnowURP? Excuse You! The Three Kafka Metrics You Need to Know
URP? Excuse You! The Three Kafka Metrics You Need to Know
 
VMworld Europe 2014: A Blueprint for Disaster Recovery of Business Critical A...
VMworld Europe 2014: A Blueprint for Disaster Recovery of Business Critical A...VMworld Europe 2014: A Blueprint for Disaster Recovery of Business Critical A...
VMworld Europe 2014: A Blueprint for Disaster Recovery of Business Critical A...
 
VMworld Europe 2014: A DevOps Story - Unlocking the Power of Docker with the ...
VMworld Europe 2014: A DevOps Story - Unlocking the Power of Docker with the ...VMworld Europe 2014: A DevOps Story - Unlocking the Power of Docker with the ...
VMworld Europe 2014: A DevOps Story - Unlocking the Power of Docker with the ...
 
BP103 - Got Problems? Let's Do a Health Check
BP103 - Got Problems? Let's Do a Health CheckBP103 - Got Problems? Let's Do a Health Check
BP103 - Got Problems? Let's Do a Health Check
 
Got Problems? Let's Do a Health Check
Got Problems? Let's Do a Health CheckGot Problems? Let's Do a Health Check
Got Problems? Let's Do a Health Check
 

En vedette

Camila ruz taller_2_historia_
Camila ruz taller_2_historia_Camila ruz taller_2_historia_
Camila ruz taller_2_historia_itachi-sama
 
Core i7 Caracteristicas, Ventajas y Desventajas
Core i7 Caracteristicas, Ventajas y DesventajasCore i7 Caracteristicas, Ventajas y Desventajas
Core i7 Caracteristicas, Ventajas y Desventajasalemar802
 
Intel Core i5
Intel Core i5 Intel Core i5
Intel Core i5 miltoninca
 
mod_php vs. FastCGI 原理与比较
mod_php vs. FastCGI 原理与比较mod_php vs. FastCGI 原理与比较
mod_php vs. FastCGI 原理与比较Ji ZHANG
 
Word press on conoha このべん #3
Word press on conoha このべん #3Word press on conoha このべん #3
Word press on conoha このべん #3Wataru OKAMOTO
 
Supercharging your PHP pages with mod_lsapi in CloudLinux OS
Supercharging your PHP pages with mod_lsapi in CloudLinux OSSupercharging your PHP pages with mod_lsapi in CloudLinux OS
Supercharging your PHP pages with mod_lsapi in CloudLinux OSCloudLinux
 
PHP7実環境ベンチ2016春
PHP7実環境ベンチ2016春PHP7実環境ベンチ2016春
PHP7実環境ベンチ2016春Ryo Tomidokoro
 
Techtalk2015 MOD_PHP vs PHP-FPM
Techtalk2015 MOD_PHP vs PHP-FPMTechtalk2015 MOD_PHP vs PHP-FPM
Techtalk2015 MOD_PHP vs PHP-FPMWebscale
 
PHP Files: An Introduction
PHP Files: An IntroductionPHP Files: An Introduction
PHP Files: An IntroductionJacques Woodcock
 
第2回勉強会資料 柏木
第2回勉強会資料 柏木第2回勉強会資料 柏木
第2回勉強会資料 柏木beyond0iwamoto
 
mod_php vs FastCGI vs FPM vs CLI
mod_php vs FastCGI vs FPM vs CLImod_php vs FastCGI vs FPM vs CLI
mod_php vs FastCGI vs FPM vs CLIJacques Woodcock
 
PHP-FPMとuWSGI——mod_php以外の選択肢を探る
PHP-FPMとuWSGI——mod_php以外の選択肢を探るPHP-FPMとuWSGI——mod_php以外の選択肢を探る
PHP-FPMとuWSGI——mod_php以外の選択肢を探るYoshio Hanawa
 
Ultrafast WordPress Virtual Word camp2015
Ultrafast WordPress Virtual  Word camp2015 Ultrafast WordPress Virtual  Word camp2015
Ultrafast WordPress Virtual Word camp2015 Yuta Sakamoto
 
realpathキャッシュと OPcacheの面倒すぎる関係
realpathキャッシュと OPcacheの面倒すぎる関係realpathキャッシュと OPcacheの面倒すぎる関係
realpathキャッシュと OPcacheの面倒すぎる関係Yoshio Hanawa
 

En vedette (20)

Running php on nginx
Running php on nginxRunning php on nginx
Running php on nginx
 
Cores2
Cores2Cores2
Cores2
 
Camila ruz taller_2_historia_
Camila ruz taller_2_historia_Camila ruz taller_2_historia_
Camila ruz taller_2_historia_
 
Core I7
Core I7Core I7
Core I7
 
Core i7 Caracteristicas, Ventajas y Desventajas
Core i7 Caracteristicas, Ventajas y DesventajasCore i7 Caracteristicas, Ventajas y Desventajas
Core i7 Caracteristicas, Ventajas y Desventajas
 
Intel Core i5
Intel Core i5 Intel Core i5
Intel Core i5
 
From LAMP to LNNP
From LAMP to LNNPFrom LAMP to LNNP
From LAMP to LNNP
 
mod_php vs. FastCGI 原理与比较
mod_php vs. FastCGI 原理与比较mod_php vs. FastCGI 原理与比较
mod_php vs. FastCGI 原理与比较
 
Word press on conoha このべん #3
Word press on conoha このべん #3Word press on conoha このべん #3
Word press on conoha このべん #3
 
Nginx + PHP
Nginx + PHPNginx + PHP
Nginx + PHP
 
Supercharging your PHP pages with mod_lsapi in CloudLinux OS
Supercharging your PHP pages with mod_lsapi in CloudLinux OSSupercharging your PHP pages with mod_lsapi in CloudLinux OS
Supercharging your PHP pages with mod_lsapi in CloudLinux OS
 
PHP7実環境ベンチ2016春
PHP7実環境ベンチ2016春PHP7実環境ベンチ2016春
PHP7実環境ベンチ2016春
 
Techtalk2015 MOD_PHP vs PHP-FPM
Techtalk2015 MOD_PHP vs PHP-FPMTechtalk2015 MOD_PHP vs PHP-FPM
Techtalk2015 MOD_PHP vs PHP-FPM
 
PHP Files: An Introduction
PHP Files: An IntroductionPHP Files: An Introduction
PHP Files: An Introduction
 
第2回勉強会資料 柏木
第2回勉強会資料 柏木第2回勉強会資料 柏木
第2回勉強会資料 柏木
 
mod_php vs FastCGI vs FPM vs CLI
mod_php vs FastCGI vs FPM vs CLImod_php vs FastCGI vs FPM vs CLI
mod_php vs FastCGI vs FPM vs CLI
 
Nginx pres
Nginx presNginx pres
Nginx pres
 
PHP-FPMとuWSGI——mod_php以外の選択肢を探る
PHP-FPMとuWSGI——mod_php以外の選択肢を探るPHP-FPMとuWSGI——mod_php以外の選択肢を探る
PHP-FPMとuWSGI——mod_php以外の選択肢を探る
 
Ultrafast WordPress Virtual Word camp2015
Ultrafast WordPress Virtual  Word camp2015 Ultrafast WordPress Virtual  Word camp2015
Ultrafast WordPress Virtual Word camp2015
 
realpathキャッシュと OPcacheの面倒すぎる関係
realpathキャッシュと OPcacheの面倒すぎる関係realpathキャッシュと OPcacheの面倒すぎる関係
realpathキャッシュと OPcacheの面倒すぎる関係
 

Similaire à High performance PHP: Scaling and getting the most out of your infrastructure

Turbocharging php applications with zend server (workshop)
Turbocharging php applications with zend server (workshop)Turbocharging php applications with zend server (workshop)
Turbocharging php applications with zend server (workshop)Eric Ritchie
 
Turbocharging php applications with zend server
Turbocharging php applications with zend serverTurbocharging php applications with zend server
Turbocharging php applications with zend serverEric Ritchie
 
PHP Apps on the Move - Migrating from In-House to Cloud
PHP Apps on the Move - Migrating from In-House to Cloud  PHP Apps on the Move - Migrating from In-House to Cloud
PHP Apps on the Move - Migrating from In-House to Cloud RightScale
 
How to scale PHP applications
How to scale PHP applicationsHow to scale PHP applications
How to scale PHP applicationsEnrico Zimuel
 
Zend Products and PHP for IBMi
Zend Products and PHP for IBMi  Zend Products and PHP for IBMi
Zend Products and PHP for IBMi Shlomo Vanunu
 
Building and managing applications fast for IBM i
Building and managing applications fast for IBM iBuilding and managing applications fast for IBM i
Building and managing applications fast for IBM iZend by Rogue Wave Software
 
Zend MVC pattern based Framework – Best for Enterprise web applications
Zend MVC pattern based Framework – Best for Enterprise web applicationsZend MVC pattern based Framework – Best for Enterprise web applications
Zend MVC pattern based Framework – Best for Enterprise web applicationsEtisbew Technology Group
 
Enhancing scalability with intelligent caching
Enhancing scalability with intelligent cachingEnhancing scalability with intelligent caching
Enhancing scalability with intelligent cachingEric Ritchie
 
What's new with Zend server
What's new with Zend serverWhat's new with Zend server
What's new with Zend serverCOMMON Europe
 
Slides from LAX & DEN usergroup meetings
Slides from LAX & DEN usergroup meetingsSlides from LAX & DEN usergroup meetings
Slides from LAX & DEN usergroup meetings10n Software, LLC
 
PHP challenge on PaaS
PHP challenge on PaaSPHP challenge on PaaS
PHP challenge on PaaSBoaz Ziniman
 
Microsoft TechDays 2011 - PHP on Windows
Microsoft TechDays 2011 - PHP on WindowsMicrosoft TechDays 2011 - PHP on Windows
Microsoft TechDays 2011 - PHP on WindowsEnterprise PHP Center
 
Red Hat for IBM System z IBM Enterprise2014 Las Vegas
Red Hat for IBM System z IBM Enterprise2014 Las Vegas Red Hat for IBM System z IBM Enterprise2014 Las Vegas
Red Hat for IBM System z IBM Enterprise2014 Las Vegas Filipe Miranda
 
The Fastest Way to Redis on Pivotal Cloud Foundry
The Fastest Way to Redis on Pivotal Cloud FoundryThe Fastest Way to Redis on Pivotal Cloud Foundry
The Fastest Way to Redis on Pivotal Cloud FoundryVMware Tanzu
 
Drinking our own champagne - z Systems Development and Test Environment V10
Drinking our own champagne - z Systems Development and Test Environment V10Drinking our own champagne - z Systems Development and Test Environment V10
Drinking our own champagne - z Systems Development and Test Environment V10DevOps for Enterprise Systems
 
Top10 list planningpostgresdeployment.2014
Top10 list planningpostgresdeployment.2014Top10 list planningpostgresdeployment.2014
Top10 list planningpostgresdeployment.2014EDB
 

Similaire à High performance PHP: Scaling and getting the most out of your infrastructure (20)

Turbocharging php applications with zend server (workshop)
Turbocharging php applications with zend server (workshop)Turbocharging php applications with zend server (workshop)
Turbocharging php applications with zend server (workshop)
 
Turbocharging php applications with zend server
Turbocharging php applications with zend serverTurbocharging php applications with zend server
Turbocharging php applications with zend server
 
PHP Apps on the Move - Migrating from In-House to Cloud
PHP Apps on the Move - Migrating from In-House to Cloud  PHP Apps on the Move - Migrating from In-House to Cloud
PHP Apps on the Move - Migrating from In-House to Cloud
 
Performance tuning PHP on IBMi
Performance tuning PHP on IBMiPerformance tuning PHP on IBMi
Performance tuning PHP on IBMi
 
How to scale PHP applications
How to scale PHP applicationsHow to scale PHP applications
How to scale PHP applications
 
Zend Products and PHP for IBMi
Zend Products and PHP for IBMi  Zend Products and PHP for IBMi
Zend Products and PHP for IBMi
 
Building and managing applications fast for IBM i
Building and managing applications fast for IBM iBuilding and managing applications fast for IBM i
Building and managing applications fast for IBM i
 
Zend MVC pattern based Framework – Best for Enterprise web applications
Zend MVC pattern based Framework – Best for Enterprise web applicationsZend MVC pattern based Framework – Best for Enterprise web applications
Zend MVC pattern based Framework – Best for Enterprise web applications
 
Enhancing scalability with intelligent caching
Enhancing scalability with intelligent cachingEnhancing scalability with intelligent caching
Enhancing scalability with intelligent caching
 
What's new with Zend server
What's new with Zend serverWhat's new with Zend server
What's new with Zend server
 
Slides from LAX & DEN usergroup meetings
Slides from LAX & DEN usergroup meetingsSlides from LAX & DEN usergroup meetings
Slides from LAX & DEN usergroup meetings
 
PHP challenge on PaaS
PHP challenge on PaaSPHP challenge on PaaS
PHP challenge on PaaS
 
Microsoft TechDays 2011 - PHP on Windows
Microsoft TechDays 2011 - PHP on WindowsMicrosoft TechDays 2011 - PHP on Windows
Microsoft TechDays 2011 - PHP on Windows
 
Zend
ZendZend
Zend
 
Red Hat for IBM System z IBM Enterprise2014 Las Vegas
Red Hat for IBM System z IBM Enterprise2014 Las Vegas Red Hat for IBM System z IBM Enterprise2014 Las Vegas
Red Hat for IBM System z IBM Enterprise2014 Las Vegas
 
The Fastest Way to Redis on Pivotal Cloud Foundry
The Fastest Way to Redis on Pivotal Cloud FoundryThe Fastest Way to Redis on Pivotal Cloud Foundry
The Fastest Way to Redis on Pivotal Cloud Foundry
 
green
greengreen
green
 
Drinking our own champagne - z Systems Development and Test Environment V10
Drinking our own champagne - z Systems Development and Test Environment V10Drinking our own champagne - z Systems Development and Test Environment V10
Drinking our own champagne - z Systems Development and Test Environment V10
 
Application Deployment on IBM i
Application Deployment on IBM iApplication Deployment on IBM i
Application Deployment on IBM i
 
Top10 list planningpostgresdeployment.2014
Top10 list planningpostgresdeployment.2014Top10 list planningpostgresdeployment.2014
Top10 list planningpostgresdeployment.2014
 

Dernier

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxRemote DBA Services
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Bhuvaneswari Subramani
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 

Dernier (20)

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 

High performance PHP: Scaling and getting the most out of your infrastructure

  • 1. © All rights reserved. Zend Technologies, Inc. High performance PHP: How do I make it go faster? Maurice Kherlakian Professional Services Consultant maurice.k@zend.com
  • 2. © All rights reserved. Zend Technologies, Inc.2 Agenda • What we will be covering  The network, database, and application aspects in optimization  Tools and techniques that assist in optimization (Code tracing, profiling)  OS level optimizations and tools  Best practices in application development for an optimized application  Server clustering  DEMO
  • 3. © All rights reserved. Zend Technologies, Inc.3 The network •Entry point into your system •Needs to be secured Firewall Layer separation: External – DMZ - internal •Unless you have one server, need to find a traffic distribution mechanism – Load balancers Different kinds of load balancers: hardware v/s software Hardware appliances are costly but robust, do layer 7 lb Software alternatives are cheaper, do a good job also • HAProxy • Ldirectord • Nginx, Apache with balancer modules
  • 4. © All rights reserved. Zend Technologies, Inc.4 The network •Reverse proxy Avoid having application servers in an externally accessible environment Can also be used to load balance Apache, nginx, lighttpd Usually reverse proxy connect to backend servers
  • 5. © All rights reserved. Zend Technologies, Inc.5 The web server •Different alternatives – choose based on performance Apache – mod_php Nginx, lighty with php-fcgi or php-fpm Windows IIS – FastCGI •Zend Server Apache-based, on Linux, Windows, IBM i Zend engine
  • 6. © All rights reserved. Zend Technologies, Inc.6 Web servers clustering •1st step towards scaling solution After moving the database to a separate server Configuration syncing: rsync, rmp/deb, svn Application code deployment ZSCM
  • 7. © All rights reserved. Zend Technologies, Inc.7 Deployment strategies •SVN as a deployment tool •RPM/deb •PEAR •Zend Server .zpk •More info: watch deployment strategies webinar (http://www.zend.com/en/resources/webinars/php) •Check out Shahar’s Best practices in deploying PHP apps
  • 8. © All rights reserved. Zend Technologies, Inc.8 Web servers session clustering •What is session clustering •Failing over to other servers •Mechanisms for session clustering Memcached Lightweight key/value server Database Zend Server SC
  • 9. © All rights reserved. Zend Technologies, Inc.9 Opcode caching •What is it, why virtually every PHP site uses it •Drastic effects of code tracing (Screenshot next slide) •Different opcode caches APC, eaccelerator, xcache Zend Server Optimizer+ •Extra performance boost – check timestamp
  • 10. © All rights reserved. Zend Technologies, Inc.10 strace with and without O+ activated •10 times less system calls with O+ active
  • 11. © All rights reserved. Zend Technologies, Inc.11 Static content •Why should we separate static/dynamic content •Techniques for content separation CDN Separate sub-domains Reverse proxying with rules for static content
  • 12. © All rights reserved. Zend Technologies, Inc.12 Handling large files •Why large files should not be served from PHP •Serve large files from a lightweight web server Lighty, nginx •Securing large files download Modules for web servers – authentication logic, then offload to web server. Usually through headers Zend Download server
  • 13. © All rights reserved. Zend Technologies, Inc.13 •To achieve an optimal cluster, many different packages •What if one solution existed that could do all this? •Zend server Optimizer + for code caching Full page caching ZSCM for server sync Code tracing/monitoring for app monitoring Zend Download server
  • 14. © All rights reserved. Zend Technologies, Inc.14 Linux (rpm/web repositories) IBM i (PTF) Windows (MSI) Application Performance Acceleration Optimization Caching Reliability & Management Monitoring Root-Cause Configuration Scale-Out Clustering Job Queue Downloads Business-grade PHP Hot Fixes Support Java Bridge Zend Framework PHP Zend Server ZendStudio(Eclipse-based) CollaborateDebugProfileTest Zend Server1
  • 15. © All rights reserved. Zend Technologies, Inc.15 Database scaling •Scaling techniques Replication Functional separation Sharding •Schemaless databases eg: MongoDB •For analytics, consider a column-oriented database like Infobright
  • 16. © All rights reserved. Zend Technologies, Inc.16 Database results caching •Shared memory (APC) •Distributed caching (memcached) •Zend Server data cache •But all of that doesn’t matter if your application is not optimized!
  • 17. © All rights reserved. Zend Technologies, Inc.17 The application •No cookbook for good application design •Don’t optimize in early development, risk over-optimization •Frameworks Frameworks can make you fall in over-architecting trap Possible mistakes using DBAL or ORM – like lazy joins End up making a lot more queries than necessary
  • 18. © All rights reserved. Zend Technologies, Inc.18 The application •Write application for what it is intended to be used •(ex: file processing: load entire file v/s one line at a time: first approach works well for a few queries, but under high load 2nd approach better)
  • 19. © All rights reserved. Zend Technologies, Inc.19 The secrets to application optimization •Using the right tools Xdebug Zend Server Code tracing (demo) Profiling (demo) •Monitor execution time and memory usage •Design intelligently •Know the hardware you’re writing for and how it operates. The more you know about it, the better your app will be
  • 20. © All rights reserved. Zend Technologies, Inc.20 Database optimizations •Statements tuning •Tables indexing •Monitor all queries to DB Use profiling tools, if using DBAL usually provides one ZF provides Zend_Db_Profiler that allows logging of queries to later study them (demo) Zend_Db_Profiler_Firebug: cool tool that allows displaying all queries on Firebug. Completely independent from page itself, no interference with JSON or XML requests •Use Explain, tune criteria, avoid lazy joins
  • 21. © All rights reserved. Zend Technologies, Inc.21 How do we fix problems •Found a bottleneck, how do we fix it? Rewrite logic to be less demanding, or more demanding, but get to endpoint faster •Caching File caching Shared mem caching Distributed (memcached) •Adding caching should be easy on a well architected app Domain model •Caching in most cases is NOT a silver bullet.
  • 22. © All rights reserved. Zend Technologies, Inc.22 High server loads •App is optimized, traffic growing, servers start to cough… •Where is the problem? •Your application can be cpu-bound, io-bound or memory bound. So how do you find out? Use tools like top, vmstat, iostat •Why is this important?
  • 23. © All rights reserved. Zend Technologies, Inc.23 Recap •Be smart! •Look at the problem, understand it, and solve it. •Using var_dump is NOT the solution, neither is shooting in the dark •Use the right toolset •Wealth of resources (white papers/webinars…) on zend.com
  • 24. © All rights reserved. Zend Technologies, Inc. Thank you! Maurice Kherlakian maurice.k@zend.com http://framework.zend.com http://www.zend.com

Notes de l'éditeur

  1. Public facing, router – then into network. LB cand do natting. Examples of hardware appliances Coyote point, Barraccuda Talk about load balancer redundancy – no SPF
  2. 10X less sytem calls with and without O+. Most of the system calls that are gone are fstat and lstat, which are both file ops. We could get even better results by not checking file timestamps.
  3. One point to talk about here is Drupal bencchmark O+ v/s APC
  4. We released Zend Server and Zend Server Community Edition in April this year Products written from scratch based on our very extensive experience with Platform technologies Full integrated stack, native installer, ZF and Studio integration, software updates, all new UI, … Both editions have been very well received by users (love performance boost, ease of use, deployment) Great fit to our partners – we’re working with Varien/Magento, KnowledgeTree, MCS, … Next step will round up web app server offering to support high availability and scalability – more on this in the next few months
  5. Infobright is one of the exhibitors here at ZendCon.
  6. ZF – remember opcode caching? Desing in modular way Application performance optimization – question to always ask yourself: 1- what am I gaining? 2- would it be cheaper to throw hardware at the problem? 3- how do I prove it. -> if gaining 2X by optimizing but cost is 3X what it would cost to buy a server and gain 1.5 or 1.8 times, decision is relatively easy. Cost v/s gain. ORM is going to return results in any way it knows -> up to you to optimize Trade-offs of performance v/s code readability and “pretty” architecture. Cf. Martin fowler on Enterprise architecture design patterns.
  7. What I mean here is that you need to start thinking about what the app is going to be used for at the early planning stage, because that will define certain design decisions you make. If low traffic, I can send 100-200 queries to db per page, they’re really fast. I can therefore use a readable code because at the code level I’m just using my most basic objects to perform CRUD. But if high traffic app, then I need to start thinking, do I really want 100-200 queries to the DB per page, or should I, instead, try to optimize this by designing special objects that perform CRUD specific to this context?
  8. A Zend Consultant’s secret weapon: Code tracing. -> DEMO Know the hardware: If I know the HW I’m writing for, if for example I’m writing a read/write heavy app, and I know that disks are particularly slow, I’ll emphathize caching. That’s valid advice for caching too by the way. If a piece of code takes 3 seconds to execute (some kind of recursive menu build), and it takes a few minutes to add caching to it, if the menu does not change often, why bother spending hours rewriting?... Better to just add caching. Performance optimization in general is an art, not a science. Like good application design.
  9. EXPLAIN is your friend. Using the power of an in application query profiler combined with EXPLAIN, you can tune your SQL statements to the dot. Demo: ZFA app (wiki) with the use of Zend_Db_Profiler Add indexes where needed, if a query is too intensive on the server, try to take some of the logic out of the query, split it into multiple subqueries and do some heavy lifting in PHP instead of the database.
  10. If you are given time, try to optimize before caching. I know I said before that if caching is easier, then go with that, but as with everything, if it’s too easy, you cache and cache, and before you knmow it, well you’re running memcached on a 40 Gb RAM server that holds a copy of your databse and you’ve written a whole architecture/layer to keep your cache in sync with DB. It’s all about balance, and that comes with experience.
  11. Explain vmstat output Important because in an ideal world, 3 limits would be hit together. But if you know what you app’s usage patterns are, then you know where to optimize, and you know what the specs to your next server are!