Download - Scalability In PHP
![Page 1: Scalability In PHP](https://reader033.vdocuments.us/reader033/viewer/2022042614/558169c9d8b42ae15f8b45d1/html5/thumbnails/1.jpg)
Scalability in PHPScalability in PHP
Optimizing your code, and Optimizing your code, and building your apps to scalebuilding your apps to scale
Ian SelbyIan SelbySenior Web Developer at AptanaSenior Web Developer at Aptanawww.aptana.com www.aptana.com
![Page 2: Scalability In PHP](https://reader033.vdocuments.us/reader033/viewer/2022042614/558169c9d8b42ae15f8b45d1/html5/thumbnails/2.jpg)
So, how do ISo, how do I
… at least how do I do it in PHP?… at least how do I do it in PHP?
Build a ScalableBuild a ScalableApp?App?
![Page 3: Scalability In PHP](https://reader033.vdocuments.us/reader033/viewer/2022042614/558169c9d8b42ae15f8b45d1/html5/thumbnails/3.jpg)
We can optimize in three places:We can optimize in three places:
![Page 4: Scalability In PHP](https://reader033.vdocuments.us/reader033/viewer/2022042614/558169c9d8b42ae15f8b45d1/html5/thumbnails/4.jpg)
Bad Practices in Coding…Bad Practices in Coding…
![Page 5: Scalability In PHP](https://reader033.vdocuments.us/reader033/viewer/2022042614/558169c9d8b42ae15f8b45d1/html5/thumbnails/5.jpg)
Bad Practices in Coding…Bad Practices in Coding…
![Page 6: Scalability In PHP](https://reader033.vdocuments.us/reader033/viewer/2022042614/558169c9d8b42ae15f8b45d1/html5/thumbnails/6.jpg)
Bad Practices in Coding…Bad Practices in Coding…
![Page 7: Scalability In PHP](https://reader033.vdocuments.us/reader033/viewer/2022042614/558169c9d8b42ae15f8b45d1/html5/thumbnails/7.jpg)
Bad Practices in Coding…Bad Practices in Coding…
![Page 8: Scalability In PHP](https://reader033.vdocuments.us/reader033/viewer/2022042614/558169c9d8b42ae15f8b45d1/html5/thumbnails/8.jpg)
Bad Practices in Coding…Bad Practices in Coding…
![Page 9: Scalability In PHP](https://reader033.vdocuments.us/reader033/viewer/2022042614/558169c9d8b42ae15f8b45d1/html5/thumbnails/9.jpg)
Good Practices in Coding…Good Practices in Coding…
![Page 10: Scalability In PHP](https://reader033.vdocuments.us/reader033/viewer/2022042614/558169c9d8b42ae15f8b45d1/html5/thumbnails/10.jpg)
Good Practices in Coding…Good Practices in Coding…
![Page 11: Scalability In PHP](https://reader033.vdocuments.us/reader033/viewer/2022042614/558169c9d8b42ae15f8b45d1/html5/thumbnails/11.jpg)
Good Practices in Coding…Good Practices in Coding…
![Page 12: Scalability In PHP](https://reader033.vdocuments.us/reader033/viewer/2022042614/558169c9d8b42ae15f8b45d1/html5/thumbnails/12.jpg)
Good Practices in Coding…Good Practices in Coding…
![Page 13: Scalability In PHP](https://reader033.vdocuments.us/reader033/viewer/2022042614/558169c9d8b42ae15f8b45d1/html5/thumbnails/13.jpg)
Now that my code is optimized,Now that my code is optimized,
How do I makeHow do I makeit run faster?it run faster?
![Page 14: Scalability In PHP](https://reader033.vdocuments.us/reader033/viewer/2022042614/558169c9d8b42ae15f8b45d1/html5/thumbnails/14.jpg)
Easy!Easy!
Use Opcode Use Opcode Caching!Caching!
Duh!Duh!
![Page 15: Scalability In PHP](https://reader033.vdocuments.us/reader033/viewer/2022042614/558169c9d8b42ae15f8b45d1/html5/thumbnails/15.jpg)
What is opcode caching?What is opcode caching?
Opcode caching optimizes PHP Opcode caching optimizes PHP intermediate code and caches intermediate code and caches
data and compiled code from the data and compiled code from the PHP bytecode compiler in shared PHP bytecode compiler in shared
memory.memory.
Opcode caching optimizes PHP Opcode caching optimizes PHP intermediate code and caches intermediate code and caches
data and compiled code from the data and compiled code from the PHP bytecode compiler in shared PHP bytecode compiler in shared
memory.memory.
![Page 16: Scalability In PHP](https://reader033.vdocuments.us/reader033/viewer/2022042614/558169c9d8b42ae15f8b45d1/html5/thumbnails/16.jpg)
![Page 17: Scalability In PHP](https://reader033.vdocuments.us/reader033/viewer/2022042614/558169c9d8b42ae15f8b45d1/html5/thumbnails/17.jpg)
What is opcode caching?What is opcode caching?
Basically, your code is pre-Basically, your code is pre-compiled, and then stored in compiled, and then stored in
memory.memory.
So, it runs faster.So, it runs faster.
Basically, your code is pre-Basically, your code is pre-compiled, and then stored in compiled, and then stored in
memory.memory.
So, it runs faster.So, it runs faster.
![Page 18: Scalability In PHP](https://reader033.vdocuments.us/reader033/viewer/2022042614/558169c9d8b42ae15f8b45d1/html5/thumbnails/18.jpg)
APC – Alternative PHP CacheAPC – Alternative PHP Cache
http://pecl.php.net/apchttp://php.net/apc
![Page 19: Scalability In PHP](https://reader033.vdocuments.us/reader033/viewer/2022042614/558169c9d8b42ae15f8b45d1/html5/thumbnails/19.jpg)
But, it gets better…But, it gets better…
You can actuallyYou can actuallycache your owncache your owndata with APC!data with APC!
Let’s take a look at that now…Let’s take a look at that now…
![Page 20: Scalability In PHP](https://reader033.vdocuments.us/reader033/viewer/2022042614/558169c9d8b42ae15f8b45d1/html5/thumbnails/20.jpg)
Source code available at gen-x-design.comSource code available at gen-x-design.com
![Page 21: Scalability In PHP](https://reader033.vdocuments.us/reader033/viewer/2022042614/558169c9d8b42ae15f8b45d1/html5/thumbnails/21.jpg)
So, my code is gooder and cached..So, my code is gooder and cached..
What can I do What can I do to speed up myto speed up mydatabase stuff?database stuff?
![Page 22: Scalability In PHP](https://reader033.vdocuments.us/reader033/viewer/2022042614/558169c9d8b42ae15f8b45d1/html5/thumbnails/22.jpg)
Speed up your database stuff…Speed up your database stuff…
![Page 23: Scalability In PHP](https://reader033.vdocuments.us/reader033/viewer/2022042614/558169c9d8b42ae15f8b45d1/html5/thumbnails/23.jpg)
Speed up your database stuff…Speed up your database stuff…
![Page 24: Scalability In PHP](https://reader033.vdocuments.us/reader033/viewer/2022042614/558169c9d8b42ae15f8b45d1/html5/thumbnails/24.jpg)
Speed up your database stuff…Speed up your database stuff…
![Page 25: Scalability In PHP](https://reader033.vdocuments.us/reader033/viewer/2022042614/558169c9d8b42ae15f8b45d1/html5/thumbnails/25.jpg)
Cool, my databases are tuned…Cool, my databases are tuned…
What kind of What kind of infrastructureinfrastructureshould I set up?should I set up?
![Page 26: Scalability In PHP](https://reader033.vdocuments.us/reader033/viewer/2022042614/558169c9d8b42ae15f8b45d1/html5/thumbnails/26.jpg)
Building a scalable infrastructureBuilding a scalable infrastructure
![Page 27: Scalability In PHP](https://reader033.vdocuments.us/reader033/viewer/2022042614/558169c9d8b42ae15f8b45d1/html5/thumbnails/27.jpg)
Building a scalable infrastructureBuilding a scalable infrastructure
http://code.google.com/p/netgearman/
![Page 28: Scalability In PHP](https://reader033.vdocuments.us/reader033/viewer/2022042614/558169c9d8b42ae15f8b45d1/html5/thumbnails/28.jpg)
Building a scalable infrastructureBuilding a scalable infrastructure
Gearman ClientGearman Client
![Page 29: Scalability In PHP](https://reader033.vdocuments.us/reader033/viewer/2022042614/558169c9d8b42ae15f8b45d1/html5/thumbnails/29.jpg)
Building a scalable infrastructureBuilding a scalable infrastructure
Gearman JobGearman Job
![Page 30: Scalability In PHP](https://reader033.vdocuments.us/reader033/viewer/2022042614/558169c9d8b42ae15f8b45d1/html5/thumbnails/30.jpg)
Building a scalable infrastructureBuilding a scalable infrastructure
Gearman WorkerGearman Worker
![Page 31: Scalability In PHP](https://reader033.vdocuments.us/reader033/viewer/2022042614/558169c9d8b42ae15f8b45d1/html5/thumbnails/31.jpg)
![Page 32: Scalability In PHP](https://reader033.vdocuments.us/reader033/viewer/2022042614/558169c9d8b42ae15f8b45d1/html5/thumbnails/32.jpg)
Building a scalable infrastructureBuilding a scalable infrastructure
http://www.aptana.com/cloud
![Page 33: Scalability In PHP](https://reader033.vdocuments.us/reader033/viewer/2022042614/558169c9d8b42ae15f8b45d1/html5/thumbnails/33.jpg)
I’ll Show YouI’ll Show YouNow!Now!
![Page 34: Scalability In PHP](https://reader033.vdocuments.us/reader033/viewer/2022042614/558169c9d8b42ae15f8b45d1/html5/thumbnails/34.jpg)
![Page 35: Scalability In PHP](https://reader033.vdocuments.us/reader033/viewer/2022042614/558169c9d8b42ae15f8b45d1/html5/thumbnails/35.jpg)
That’s It!That’s It!For more information, and to ask any For more information, and to ask any
questions, visit us on the web:questions, visit us on the web:
www.aptana.comwww.aptana.com
Contact me: [email protected] me: [email protected]
To download studio, visit www.aptana.com/studio