35
Scalability Scalability in PHP in PHP Optimizing your code, Optimizing your code, and building your apps and building your apps to scale to scale Ian Selby Ian Selby Senior Web Developer at Aptana Senior Web Developer at Aptana www.aptana.com www.aptana.com

Scalability In PHP

Embed Size (px)

DESCRIPTION

Optimizing code, opcode caching, and building PHP apps to scale properly

Citation preview

Page 1: Scalability In PHP

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

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

We can optimize in three places:We can optimize in three places:

Page 4: Scalability In PHP

Bad Practices in Coding…Bad Practices in Coding…

Page 5: Scalability In PHP

Bad Practices in Coding…Bad Practices in Coding…

Page 6: Scalability In PHP

Bad Practices in Coding…Bad Practices in Coding…

Page 7: Scalability In PHP

Bad Practices in Coding…Bad Practices in Coding…

Page 8: Scalability In PHP

Bad Practices in Coding…Bad Practices in Coding…

Page 9: Scalability In PHP

Good Practices in Coding…Good Practices in Coding…

Page 10: Scalability In PHP

Good Practices in Coding…Good Practices in Coding…

Page 11: Scalability In PHP

Good Practices in Coding…Good Practices in Coding…

Page 12: Scalability In PHP

Good Practices in Coding…Good Practices in Coding…

Page 13: Scalability In PHP

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

Easy!Easy!

Use Opcode Use Opcode Caching!Caching!

Duh!Duh!

Page 15: Scalability In PHP

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
Page 17: Scalability In PHP

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

APC – Alternative PHP CacheAPC – Alternative PHP Cache

http://pecl.php.net/apchttp://php.net/apc

Page 19: Scalability In PHP

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

Source code available at gen-x-design.comSource code available at gen-x-design.com

Page 21: Scalability In PHP

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

Speed up your database stuff…Speed up your database stuff…

Page 23: Scalability In PHP

Speed up your database stuff…Speed up your database stuff…

Page 24: Scalability In PHP

Speed up your database stuff…Speed up your database stuff…

Page 25: Scalability In PHP

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

Building a scalable infrastructureBuilding a scalable infrastructure

Page 27: Scalability In PHP

Building a scalable infrastructureBuilding a scalable infrastructure

http://code.google.com/p/netgearman/

Page 28: Scalability In PHP

Building a scalable infrastructureBuilding a scalable infrastructure

Gearman ClientGearman Client

Page 29: Scalability In PHP

Building a scalable infrastructureBuilding a scalable infrastructure

Gearman JobGearman Job

Page 30: Scalability In PHP

Building a scalable infrastructureBuilding a scalable infrastructure

Gearman WorkerGearman Worker

Page 31: Scalability In PHP
Page 32: Scalability In PHP

Building a scalable infrastructureBuilding a scalable infrastructure

http://www.aptana.com/cloud

Page 33: Scalability In PHP

I’ll Show YouI’ll Show YouNow!Now!

Page 34: Scalability In PHP
Page 35: Scalability In PHP

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