Upload
phptechtalk
View
1.195
Download
0
Tags:
Embed Size (px)
DESCRIPTION
"Accelarating PHP Applications" Presented at INTAN Sabah Technology Updates 2011
Citation preview
www.mimos.my © 2009 MIMOS Berhad. All Rights Reserved.
Accelerating PHPApplications
Errazudin Ishak
Who Am I
PHP Center of Excellence
The Curious Case of Enterprise PHP
Summary
Agenda
www.mimos.my © 2011 MIMOS Berhad. All Rights Reserved.
Senior engineer @ Mimos Berhad
Focuses on web application development, deployment, performance and stability.
2009 : foss.my , MyGOSSCON
2010 : Entp. PHP Techtalk, BarcampKL, PHP Meetup, MOSC2010, PHPNW UK, PHP20102010, MyGOSSCON
Me
www.mimos.my © 2011 MIMOS Berhad. All Rights Reserved.
Agenda
www.mimos.my © 2011 MIMOS Berhad. All Rights Reserved.
Who Am I
PHP Centre of Excellence
The Curious Case of Enterprise PHP
Summary
www.mimos.my © 2011 MIMOS Berhad. All Rights Reserved.
phpcoe.mimos.my
www.mimos.my © 2011 MIMOS Berhad. All Rights Reserved.
phpcoe.mimos.my
Top goals;
• increasing the maturity of the PHP application life cycle,
• showcasing the best practice of enterprise PHP development
• contributing to/supporting PHP open source projects
• supporting PHP user groups/communities
• organizing conferences/seminar
• developing localized training material
• forming and maintaining partnerships with the communities and developing professional services.
www.mimos.my © 2011 MIMOS Berhad. All Rights Reserved.
Events : Enterprise PHP Tech talk
www.mimos.my © 2011 MIMOS Berhad. All Rights Reserved.
Events : Facebook Developer Garage
www.mimos.my © 2011 MIMOS Berhad. All Rights Reserved.
Events : PHP Malaysia Meetup
www.mimos.my © 2011 MIMOS Berhad. All Rights Reserved.
Events : PHP Northwest, UK
www.mimos.my © 2011 MIMOS Berhad. All Rights Reserved.
Accelerating PHP Application
http://goo.gl/EbTI
www.mimos.my © 2011 MIMOS Berhad. All Rights Reserved.
The News
www.mimos.my © 2011 MIMOS Berhad. All Rights Reserved.
iSDPIntelligent Service Delivery Platform
www.mimos.my © 2011 MIMOS Berhad. All Rights Reserved.
The struggle begins..
Who Am I
PHP Center of Excellence
The Curious Case of Enterprise PHP (How actually we makes PHP apps fly)
Summary
Agenda
www.mimos.my © 2011 MIMOS Berhad. All Rights Reserved.
www.mimos.my © 2011 MIMOS Berhad. All Rights Reserved.
Enterprise == ?
Enterprise PHP
www.mimos.my © 2011 MIMOS Berhad. All Rights Reserved.
BA
Designer
Project Lead
DBA
Tester
PM
Sys. AdPHP Geek
TEAM
Enterprise PHP
www.mimos.my © 2011 MIMOS Berhad. All Rights Reserved.
TEAM
Requirement
•Customer need this …•User want that …•My boss add this …•My BA... more headache …
www.mimos.my © 2011 MIMOS Berhad. All Rights Reserved.
"Faster sites create happy users” – Google, April 9, 2010
http://www.flickr.com/photos/36230948@N05/
• Planning
oRequirement Analysis
oDesign
• Execution
oCode
oTest
• Deployment
oSys Adm nightmare?
Web Application Lifecycle
www.mimos.my © 2011 MIMOS Berhad. All Rights Reserved.
• Planning
oRequirement Analysis
oDesign
• Execution
oCode
oTest
• Deployment
oSys Adm nightmare?
Web Application Lifecycle
www.mimos.my © 2011 MIMOS Berhad. All Rights Reserved.
• Planning
oRequirement Analysis
oDesign
• Execution
oCode
oTest
• Deployment
oSys Adm nightmare?
Web Application Lifecycle
www.mimos.my © 2011 MIMOS Berhad. All Rights Reserved.
Enterprise PHP
www.mimos.my © 2011 MIMOS Berhad. All Rights Reserved.
TEAMRequirement
Architecture
•Design Diagrams (Technical )•HLD•Blueprint
www.mimos.my © 2011 MIMOS Berhad. All Rights Reserved.
"Real performance is architecture-driven”- R.Lerdorf
http://goo.gl/abCVp
www.mimos.my © 2011 MIMOS Berhad. All Rights Reserved.
"PHP is rarely the bottleneck”
-R.Lerdorf
www.mimos.my © 2011 MIMOS Berhad. All Rights Reserved.
Front End
Back End
www.mimos.my © 2011 MIMOS Berhad. All Rights Reserved.
Front End
nginx Zend Server
www.mimos.my © 2011 MIMOS Berhad. All Rights Reserved.
Back End
Zend Server
MySQL
Enterprise PHP
www.mimos.my © 2011 MIMOS Berhad. All Rights Reserved.
TEAMRequirementArchitecture
Tools
•Planning•Development•Deployment
Enterprise PHP
www.mimos.my © 2011 MIMOS Berhad. All Rights Reserved.
TEAMRequirementArchitectureTools
Foundation
•Stable?•Framework vs No-Framework•On Your Own Frame to-do work
Enterprise PHP
www.mimos.my © 2011 MIMOS Berhad. All Rights Reserved.
TEAMRequirementArchitectureToolsFoundation
Design patterns
•Best practice of solving probs.•MVC?
Enterprise PHP
www.mimos.my © 2011 MIMOS Berhad. All Rights Reserved.
TEAMRequirementArchitectureToolsFoundationDesign patterns
Testing
•Developer, Unit, Functional, Performance, Integration,Usability
Enterprise PHP
www.mimos.my © 2011 MIMOS Berhad. All Rights Reserved.
TEAMRequirementArchitectureToolsFoundationDesign patternsTesting
Optimization
•They want it fast•We need
•Accelerator (eAccelerator, Alternative PHP Cache, ionCubePHP Accelerator,Turck MMCache,XCache,NuspherePhpExpress,Zend Optimizer+,Zend Platform •Cache (Smarty, Zend_Cache, Memcached)
www.mimos.my © 2011 MIMOS Berhad. All Rights Reserved.
"Premature optimization is the root of all evil ”- Donald Knuth
http://goo.gl/twTea
• System calls
oweb server processes
o Index
oWeb server config
o Include
o S-L-D-Ktrace / truss
Where to start
www.mimos.my © 2011 MIMOS Berhad. All Rights Reserved.
• Include hierachy > redundancy
oTools > pecl/inclued
o include_once/require_once
oGraph
Find the culprit
www.mimos.my © 2011 MIMOS Berhad. All Rights Reserved.
www.mimos.my © 2011 MIMOS Berhad. All Rights Reserved.
"Profile your code to pinpoint bottlenecks”
- Eric Higgins
• Code
• Network
• DB
• System
Areas
www.mimos.my © 2011 MIMOS Berhad. All Rights Reserved.
• xdebug
• valgrind.org
• Xhprof
• Zend Studio/Server
Profiling Tools
www.mimos.my © 2011 MIMOS Berhad. All Rights Reserved.
Enterprise PHP
www.mimos.my © 2011 MIMOS Berhad. All Rights Reserved.
TEAMRequirementArchitectureToolsFoundationDesign patternsTestingOptimization
Security
•Prevention of harmful event(s)•Real Risk•Severe consequences
http://goo.gl/nPgwj
Enterprise PHP
www.mimos.my © 2011 MIMOS Berhad. All Rights Reserved.
TEAMRequirementArchitectureToolsFoundationDesign patternsTestingOptimizationSecurity
Deployment
•Develop, Test, Deploy (Test, Live)•Simple XAMPP to HA, Scalable architecture
www.mimos.my © 2011 MIMOS Berhad. All Rights Reserved.
“Every nanoseconds count!” - My Big Boss(your boss also)
http://geekonfilm.files.wordpress.com/2009/09/vader.jpg
• Design
o Algorithm used
o Architecture
o Special tricks
• Code
o Avoid ‘slowdowns’
• Deploy
o “it works on my dev machine!”
Layers
www.mimos.my © 2011 MIMOS Berhad. All Rights Reserved.
• Measure
• Benchmark
• Analyse
• (Loop?)
Performance Enhancement
www.mimos.my © 2011 MIMOS Berhad. All Rights Reserved.
• Avoid Premature Optimization
• Measuring Performance
oMemory and CPU Measurement
o Requests Per Second
• Pinpointing The Cause Of Poor Performance
• Code Profiling
• Database Operations Analysis
• General PHP Optimisation
o Opcode Caching
o Realpath Cache
Key Points
www.mimos.my © 2011 MIMOS Berhad. All Rights Reserved.
• General Zend Framework Optimization
o Class Loading Optimisation
o Configuring Default Caches
o Cache At The Right Level
o Minimising Include Paths
• HTTP Server Optimization
o Optimising Apache's Configuration
o Avoiding Apache Completely
Key Points
www.mimos.my © 2011 MIMOS Berhad. All Rights Reserved.
Enterprise PHP
www.mimos.my © 2011 MIMOS Berhad. All Rights Reserved.
TEAMRequirementArchitectureToolsFoundationDesign patternsTestingOptimizationSecurityDeployment
Operation•Helpdesk•Monitoring•Root cause analysis•Change management
Enterprise PHP
www.mimos.my © 2011 MIMOS Berhad. All Rights Reserved.
TEAMRequirementArchitectureToolsFoundationDesign patternsTestingOptimizationSecurityDeploymentOperation
Who Am I
PHP Center of Excellence
The Curious Case of Enterprise PHP
Summary
Agenda
www.mimos.my © 2011 MIMOS Berhad. All Rights Reserved.
• Objectives & constraints
• What is the Problems
• Don’t make assumptions (VNV it)
• Right tools (but tools is just a tools)
• Use profiler with benchmarks
• Resources are limited (monitor them)
Checklist
www.mimos.my © 2011 MIMOS Berhad. All Rights Reserved.
www.mimos.my © 2011 MIMOS Berhad. All Rights Reserved.
Ready to make your web apps fly?
http://goo.gl/abCVp
Resources
www.mimos.my © 2011 MIMOS Berhad. All Rights Reserved.
• Eric Higgins, Google Webmaster code.google.com/speed/articles/optimizing-php.html
• Rasmus’s talk at Hacker Dojo http://talks.php.net/show/digg/
• code.google.com/speed/page-speed
• developer.yahoo.com/performance/rules.html
• www.zend.com/en/products/server
• www.nginx.net
• www.survivethedeepend.com
• pecl.php.net/package/xhprof
• github.com/facebook/xhprof
THANK YOU
www.mimos.my © 2009 MIMOS Berhad. All Rights Reserved.
@errazudin
* All images, logos and data are the copyright of their respective owners