Beruflich Dokumente
Kultur Dokumente
Eli White
Zend
http://eliw.com/
Scaling?
Eli White — Habits of Highly Scalable Web Applications — Dutch PHP Conference 2009 — 6/13/2009
Various aspects
Web Server
Database
Caching
Eli White — Habits of Highly Scalable Web Applications — Dutch PHP Conference 2009 — 6/13/2009
In the Beginning …
Eli White — Habits of Highly Scalable Web Applications — Dutch PHP Conference 2009 — 6/13/2009
Load Balanced
Eli White — Habits of Highly Scalable Web Applications — Dutch PHP Conference 2009 — 6/13/2009
Numerous Options
NetScaler
DNS Rotation
Apache Proxy BIG-IP
Cloud Services
Eli White — Habits of Highly Scalable Web Applications — Dutch PHP Conference 2009 — 6/13/2009
Preparation
Ensure you don't preclude this, for example:
If using local caching (APC / Zend Server)
Avoid assuming exclusive/single cache
Don't rely on the filesystem
Temporary files, Sessions, etc
Eli White — Habits of Highly Scalable Web Applications — Dutch PHP Conference 2009 — 6/13/2009
Database Scaling
Eli White — Habits of Highly Scalable Web Applications — Dutch PHP Conference 2009 — 6/13/2009
Step One: Master/Slave
Eli White — Habits of Highly Scalable Web Applications — Dutch PHP Conference 2009 — 6/13/2009
Master/Slave Preparation
Eli White — Habits of Highly Scalable Web Applications — Dutch PHP Conference 2009 — 6/13/2009
Avoid Slave Lag
Eli White — Habits of Highly Scalable Web Applications — Dutch PHP Conference 2009 — 6/13/2009
Step Two: Multiple Slaves
Eli White — Habits of Highly Scalable Web Applications — Dutch PHP Conference 2009 — 6/13/2009
One Slave per Web Server?
Not as flexible
Eli White — Habits of Highly Scalable Web Applications — Dutch PHP Conference 2009 — 6/13/2009
Better Solution: Random
Eli White — Habits of Highly Scalable Web Applications — Dutch PHP Conference 2009 — 6/13/2009
Code to Select Random Slave
class DB {
private static $cfg = array(
'write' =>
array('mysql:dbname=MyDB;host=10.1.2.3'),
'read' =>
array('mysql:dbname=MyDB;host=10.1.2.7',
'mysql:dbname=MyDB;host=10.1.2.8',
'mysql:dbname=MyDB;host=10.1.2.9');
);
Eli White — Habits of Highly Scalable Web Applications — Dutch PHP Conference 2009 — 6/13/2009
Step Three: Slave Pools
Eli White — Habits of Highly Scalable Web Applications — Dutch PHP Conference 2009 — 6/13/2009
Possible Pool Layout
Eli White — Habits of Highly Scalable Web Applications — Dutch PHP Conference 2009 — 6/13/2009
Step Four: Partitioning
Simplest Definition:
Break your tables or databases into smaller ones
Eli White — Habits of Highly Scalable Web Applications — Dutch PHP Conference 2009 — 6/13/2009
Multiple Masters
Eli White — Habits of Highly Scalable Web Applications — Dutch PHP Conference 2009 — 6/13/2009
Cons of Partitioning
Eli White — Habits of Highly Scalable Web Applications — Dutch PHP Conference 2009 — 6/13/2009
Main Types of Partitioning
Vertical Horizontal
Application Level
Eli White — Habits of Highly Scalable Web Applications — Dutch PHP Conference 2009 — 6/13/2009
Vertical Partitioning
Various methodologies:
● Move rarely used columns into auxiliary table
● Move often empty columns into auxiliary table
● Move columns that are not used in where clauses
Eli White — Habits of Highly Scalable Web Applications — Dutch PHP Conference 2009 — 6/13/2009
Vertical Partitioning
Eli White — Habits of Highly Scalable Web Applications — Dutch PHP Conference 2009 — 6/13/2009
Horizontal Partitioning
Various methodologies:
● Range Based
● Date Based
● Interlaced
● User Based
Eli White — Habits of Highly Scalable Web Applications — Dutch PHP Conference 2009 — 6/13/2009
Horizontal Partitioning
Eli White — Habits of Highly Scalable Web Applications — Dutch PHP Conference 2009 — 6/13/2009
Application Level Partitioning
Various methodologies:
● Move single tables to specific servers
● Move groups of related tables together to allow joining
Eli White — Habits of Highly Scalable Web Applications — Dutch PHP Conference 2009 — 6/13/2009
Application Level Partitioning
Eli White — Habits of Highly Scalable Web Applications — Dutch PHP Conference 2009 — 6/13/2009
Multiple Datacenters
Good luck!
Eli White — Habits of Highly Scalable Web Applications — Dutch PHP Conference 2009 — 6/13/2009
Brief Touch on Caching
Eli White — Habits of Highly Scalable Web Applications — Dutch PHP Conference 2009 — 6/13/2009
Type of Caching
Distributed
Memcached or Zend Platform
Required for true scalability enhancement
Eli White — Habits of Highly Scalable Web Applications — Dutch PHP Conference 2009 — 6/13/2009
Caching Best Practices
Eli White — Habits of Highly Scalable Web Applications — Dutch PHP Conference 2009 — 6/13/2009
Questions?
Twitter: @eliw
Zend's DevZone:
http://dz.zend.com/