symfony e grandi numeri: si può fare!

28
Symfony e grandi numeri Si...può...fare! Daniel Londero [email protected]

Upload: daniel-londero

Post on 14-Dec-2014

2.201 views

Category:

Technology


0 download

DESCRIPTION

 

TRANSCRIPT

Page 1: Symfony e grandi numeri: si può fare!

Symfony e grandi numeriSi...può...fare!

Daniel Londero

[email protected]

Page 2: Symfony e grandi numeri: si può fare!

Chi sono

Daniel Londero

➢ Sviluppatore PHP dal 2005 @

➢ (s|S)ymfony framework

➢ PUG Friuli

➢ Runner

Page 3: Symfony e grandi numeri: si può fare!

2M500k

5M 300k

10k 10M200k

50k 100k

Page 4: Symfony e grandi numeri: si può fare!

➢ Nasce nel 1996

➢ Nel 2006 arriva in STH

➢ Nel 2010 si passa a symfony 1.4

➢ 12 aprile 2010 revision 1

➢ 10 giugno 2010: deploy (22 ore)

Calciomercato.com: la storia

Page 5: Symfony e grandi numeri: si può fare!

I numeri

UTENTI UNICIAL MESE

PAGINE VISTEAL MESE

AGOSTO 2010 3,6M 36M

GENNAIO 2011 3,3M 32M

MARZO 2011 2,2M 28M

Page 6: Symfony e grandi numeri: si può fare!

➢ Opensource

➢ Community

➢ Documentato

➢ Test

➢ Best practice (MVC / DRY / KISS / ...)

Perchè symfony?

Page 7: Symfony e grandi numeri: si può fare!
Page 8: Symfony e grandi numeri: si può fare!
Page 9: Symfony e grandi numeri: si può fare!

#GAC

Page 10: Symfony e grandi numeri: si può fare!

LOAD BALANCER

NGINX 1PHP FCGI

BE

LOAD BALANCER

MASTERDB

SLAVEDB1

SLAVEDBN

NFS

. . .

MEMCACHED

APC

NGINX NPHP FCGI

MEMCACHED

APC

NGINX 1 NGINX N

DATA

APPLICATION

Page 11: Symfony e grandi numeri: si può fare!

LOAD BALANCER

NGINX 1PHP FCGI

BE

LOAD BALANCER

MASTERDB

SLAVEDB1

SLAVEDBN

NFS

. . .

MEMCACHED

APC

NGINX NPHP FCGI

MEMCACHED

APC

NGINX 1 NGINX N

Page 12: Symfony e grandi numeri: si può fare!

Scalare: orizzontale vs verticale

Orizzontale➢ Aggiungo macchine➢ Aumenta complessità➢ Costi e rischi più bassi

Verticale➢ Aggiungo risorse➢ Bassa complessità➢ Costi e rischi elevati

Page 13: Symfony e grandi numeri: si può fare!

Gestione delle sessioni

➢ Balancer persistenti

➢ NFS (sconsigliato)

➢ Database

➢ Memcached (Redis dalla 2.4)

Page 14: Symfony e grandi numeri: si può fare!

LOAD BALANCER

NGINX 1PHP FCGI

BE

LOAD BALANCER

MASTERDB

SLAVEDB1

SLAVEDBN

NFS

. . .

MEMCACHED

APC

NGINX NPHP FCGI

MEMCACHED

APC

NGINX 1 NGINX N

Page 15: Symfony e grandi numeri: si può fare!

Cache storage system

➢ SfFileCache (default)

➢ SfAPCCache

➢ SfEAcceleratorCache

➢ SfMemcacheCache

➢ SfSQLiteCache

➢ sfXCacheCache

Page 16: Symfony e grandi numeri: si può fare!

“There are only two hard things in Computer Science: cache invalidation and naming things”

- Phil Karlton

Page 17: Symfony e grandi numeri: si può fare!

Cache pagina

Page 18: Symfony e grandi numeri: si può fare!

Cache Partial e Component

Page 19: Symfony e grandi numeri: si può fare!

Contatori

Sfruttare la velocità di accesso alla memoria per sollevare i database da operazioni inutili.

➢ Impression sui banner

➢ Letture articoli

➢ Voti per i sondaggi

Page 20: Symfony e grandi numeri: si può fare!

LOAD BALANCER

NGINX 1PHP FCGI

BE

LOAD BALANCER

MASTERDB

SLAVEDB1

SLAVEDBN

NFS

. . .

MEMCACHED

APC

NGINX NPHP FCGI

MEMCACHED

APC

NGINX 1 NGINX N

Page 21: Symfony e grandi numeri: si può fare!

LOAD BALANCER

NGINX 1PHP FCGI

BE

LOAD BALANCER

MASTERDB

SLAVEDB1

SLAVEDBN

NFS

. . .

MEMCACHED

APC

NGINX NPHP FCGI

MEMCACHED

APC

NGINX 1 NGINX N

Page 22: Symfony e grandi numeri: si può fare!

sfMasterSlavePluginall: master: class: sfDoctrineDatabase param: dsn: mysql:dbname=database;host:master.example.com username: root password: ~ slave: class: sfDoctrineDatabase param: dsn: mysql:dbname=database;host:slave.example.com username: root password: ~

dev: master: &master class: sfDoctrineDatabase param: dsn: mysql:dbname=database;host=localhost username: root password: ~ slave: *master

Page 23: Symfony e grandi numeri: si può fare!

Strumenti utili

➢ Web debug toolbar

➢ Slow query log

➢ Explain

➢ Live on stage (and dev)

Page 24: Symfony e grandi numeri: si può fare!

LOAD BALANCER

NGINX 1PHP FCGI

BE

LOAD BALANCER

MASTERDB

SLAVEDB1

SLAVEDBN

NFS

. . .

MEMCACHED

APC

NGINX NPHP FCGI

MEMCACHED

APC

NGINX 1 NGINX N

Page 25: Symfony e grandi numeri: si può fare!

LOAD BALANCER

NGINX 1PHP FCGI

BE

LOAD BALANCER

MASTERDB

SLAVEDB1

SLAVEDBN

NFS

. . .

MEMCACHED

APC

NGINX NPHP FCGI

MEMCACHED

APC

NGINX 1 NGINX N

Page 26: Symfony e grandi numeri: si può fare!
Page 27: Symfony e grandi numeri: si può fare!

Credits e linkhttp://www.flickr.com/photos/theplanetdotcom/4879419788

http://www.php.net/manual/en/book.memcache.php

http://www.symfony-project.org/reference/1_4/en/05-Factories

http://www.symfony-project.org/gentle-introduction/1_4/en/12-Caching

http://www.symfony-project.org/jobeet/1_4/Doctrine/en/21

http://www.symfony-project.org/plugins/sfDoctrineMasterSlavePlugin

http://dev.mysql.com/doc/refman/5.6/en/slow-query-log.html

http://dev.mysql.com/doc/refman/5.6/en/explain.html

Page 28: Symfony e grandi numeri: si può fare!

Grazie. Attendo feedback...

Votate questo talkhttp://joind.in/3024

[email protected] | @dlondero | phpblog.it