The document discusses scaling a PHP application using database sharding and Amazon Web Services. It describes using MySQL databases sharded across multiple database servers to improve scalability. Key points include using an application driver to determine which shard to write to, caching static files and data, and leveraging various Amazon services like S3, EC2, CloudWatch, and Route 53. Benefits of this approach include smaller, faster databases that are easier to manage and scale out writes by adding additional database shards.
1 of 154
Download to read offline
More Related Content
2013 - Matías Paterlini: Escalando PHP con sharding y Amazon Web Services
1. Escalando una PHP App
con DB Sharding & Amazon Web Services
Matias Paterlini
Tuesday, November 5, 13
2. Objetivo de la charla
• Contar quien soy y qué hago
• Mostrar orígenes de la arquitectura, infraestructura y
escalabilidad de TFM
• Hablar de DB Sharding
• Hablar de Amazon
• Preguntas
• Cof Cof reclutar Ejem!
Tuesday, November 5, 13
3. • +11 años de experiencia en PHP.
• 6 años desarrollando aplicaciones sobre Redes
Sociales
• 25 empleados, + de 250 aplicaciones desarrolladas
• + 10K clientes, + 10M Usuarios
• 2 compañías construidas sobre plataformas sociales
Tuesday, November 5, 13
45. <?
class Caja{
var $alto;
var $ancho;
var $largo;
var $contenido;
var $color;
function introduce($cosa){
$this->contenido = $cosa;
}
function muestra_contenido(){
echo $this->contenido;
}
}
?>
Tuesday, November 5, 13
82. Static File Caching
Web Server
1
(Transaccional,
read-write)
Master
Database
Web Server
2
Web Server
3
Data Caching
Slave
Database
(read)
Tuesday, November 5, 13
Slave
Database
(read)
84. Static File Caching
Web Server
1
(Transaccional,
read-write)
Master
Database
Web Server
2
Web Server
3
Data Caching
Slave
Database
(read)
Tuesday, November 5, 13
Slave
Database
(read)
87. Static File Caching
Web Server
1
(Transaccional,
read-write)
Master
Database
Web Server
2
Web Server
3
Data Caching
Slave
Database
(read)
Tuesday, November 5, 13
Slave
Database
(read)
91. • MAAAAANY Records - Storage issues
• Caching not enough
Tuesday, November 5, 13
92. • MAAAAANY Records - Storage issues
• Caching not enough
• Alters lock tables for hours!
Tuesday, November 5, 13
93. • MAAAAANY Records - Storage issues
• Caching not enough
• Alters lock tables for hours!
• Maintenance Issues
Tuesday, November 5, 13
94. • MAAAAANY Records - Storage issues
• Caching not enough
• Alters lock tables for hours!
• Maintenance Issues
• Too much response time
Tuesday, November 5, 13
114. File Caching
Web Server
1
Web Server
2
Web Server
3
Data Caching
DB Server 1
Shard 1 Shard 4 Shard 7 Shard 10
Shard 2 Shard 5 Shard 8 Shard 11
Shard 3 Shard 6 Shard 9 Shard 12
Database Backups
Tuesday, November 5, 13
}
Databases
115. Static File Caching
Web Server
1
Web Server
2
Web Server
3
Web Server
3
DB
Server
1
DB
Server
2
DB
Server
3
DB
Server
4
Shard 1
Shard 2
Shard 3
Shard 4
Shard 5
Shard 6
Shard 7
Shard 8
Shard 9
Shard 10
Shard 11
Shard 12
Database Backups per Shard
Tuesday, November 5, 13
117. • Bases de datos más pequeñas son más
fáciles de manejar
• Bases de datos más chicas son más rápidas
• El sharding puede reducir costos
Tuesday, November 5, 13
118. • Server maintenance per db-server
• Data Maintenance Per db-shard
• NO ALTERS on tables
• Easy recovery and replication with MultiAZ
• Easy scaling
• Easy migration to other No-SQL data
engines
Tuesday, November 5, 13
119. ¿When is DB sharding
Appropiate?
Tuesday, November 5, 13