SlideShare a Scribd company logo
Esempio di Architettura Distribuita
      basata su PHP, CouchDB e Mobile
                               PHP Goes Mobile, Milano 13-04-2012




Stefano Maraspin   @maraspin
Stefano Maraspin
    Managing Partner di MV Associati

    Membro Fondatore del PUG Friuli
    PHP 5 ZCE




        @maraspin
         s.maraspin@mvassociati.it




2
IL CONTESTO
Esempio di architettura distribuita basata su PHP, CouchDB e Mobile
DOVE VOGLIAMO ARRIVARE?
RAPIDITA’
RISPARMIO
FEEDBACK
FASCINO
I CLIENTI ORDINANO…
LA CUCINA RICEVE
FEEDBACK / REAZIONE IMMEDIATI
Esempio di architettura distribuita basata su PHP, CouchDB e Mobile
Partiamo da...




14
…E SE?
Allora...




16
Cosa scegliere?




17
Incontriamo Mr. Brewer




        http://www.julianbrowne.com/article/viewer/brewers-cap-theorem
            http://ksat.me/a-plain-english-introduction-to-cap-theorem/

18
Scelta Fatta!




19
Cos’è CouchDB?
     •   Datastore Documentale (schemaless)
     •   Database / Documenti
     •   JSON
     •   REST




20
Incontriamo Futon




21
Replicazione Semplice




             Supporto per modalità PULL e PUSH

22
Ma Semplice Davvero!




         Aggiornati non solo i dati ma anche le viste (design docs)

23
Versioni
     •   ID / _rev
     •   Aggiornamento ottimista, senza lock
     •   MVCC
     •   Aggiornamenti atomici sui documenti
     •   Coerenza Eventuale




24
Scenario di conflitto




              CouchDB – The definitive guide – O’Reilly

25
Risoluzione del Conflitto




              CouchDB – The definitive guide – O’Reilly

26
CouchApps




27
Implicazione




28
SAREMO PRESTO DISOCCUPATI!
…o forse no




30
Classico Backend




31
Business Logic




32
Poi tutto impacchettato




33
Mandato a CouchDB




             Localmente, poi si arrangia lui…

34
E QUINDI PRESENTATO AI CLIENT
L’ELEFANTE LA SPUNTA SEMPRE!
Parecchia scelta
     •   Chill
     •   Doctrine CouchDB
     •   PHP CouchDB Extension
     •   PHPillow
     •   Sag
     •   Settee
     •   Plain CURL (don’t forget it’s HTTP)



37
UNA PALLOTTOLA D’ARGENTO?
Alto consumo di disco
           16000
                        DB Size (MB)
           14000


           12000


           10000


            8000


            6000


            4000


            2000


               0


                   NB Quanto sopra su update!



39
Che Succede?




            Questione di affidabilità, performance



40
C’è dell’altro
     •   Mantenuta traccia dei documenti eliminati
         (replicazione)
     •   Spazio su disco viene dedicato anche alle
         viste (che vengono precalcolate e quindi
         mantenute incrementalmente)
     •   Quando si esegue la compattazione, fa
         prima una copia di tutti i dati



41
COMPATTIAMO QUANDO POSSIBILE…
Raw Performance
     •   3000 evt/sec in batch mode
     •   400 evt/sec inserimento
     •   100 evt/sec update
     •   10 evt/sec update durante compattazione




43
Possiamo sempre scalare…




44
O forse no?




45
Una soluzione al problema




46
La Morale
     •   CouchDB è un’ottima soluzione per
         contesti distribuiti
     •   Non è adatto per le situazioni in cui ci
         siano frequenti aggiornamenti sui dati e
         carichi (ingenti) costanti
     •   L’API REST ci aiuta a scalare le letture
     •   Bigcouch viene in aiuto sulle scritture
     •   L’utilizzo combinato di PHP e couchapp
         sembra una strada promettente

47
DOMANDE?
Photo Credits
     •   http://www.flickr.com/photos/saechang/4402720421/
     •   http://www.flickr.com/photos/koocbor/4738285092/
     •   http://www.flickr.com/photos/whykkk/6311281715/
     •   http://www.flickr.com/photos/whykkk/6311776616/
     •   http://www.flickr.com/photos/neeta_lind/2517034517/
     •   http://www.flickr.com/photos/sebastian_bergmann/2087764869/
     •   http://www.flickr.com/photos/mr_g_travels/863720665/sizes/l/in/photostream/
     •   http://www.flickr.com/photos/dobs/4128798936/sizes/l/in/photostream/
     •   other pictures come from fotolia archives




49
Grazie per l’attenzione




Stefano Maraspin
@maraspin
s.maraspin@mvassociati.it

More Related Content

PDF
CouchApps: Requiem for Accidental Complexity
PDF
Polyglot Persistance con PostgreSQL, CouchDB, MongoDB, Redis e OrientDB
PDF
Codemotion 2014 : ottimizzare JAVA e PHP su un’architettura Raspberry Pi Cluster
ODP
Succo di lampone: come ottimizzare JAVA e PHP su un'architettura Raspberry Pi...
PDF
Come l’Open Source può essere alla base di un business di successo: il caso H...
PPTX
OrientDB & Big Data
PDF
Applicazioni HTML5 Superveloci - Salvatore Romeo
PDF
VMUGIT - Virtualizzare con i piedi per terra
CouchApps: Requiem for Accidental Complexity
Polyglot Persistance con PostgreSQL, CouchDB, MongoDB, Redis e OrientDB
Codemotion 2014 : ottimizzare JAVA e PHP su un’architettura Raspberry Pi Cluster
Succo di lampone: come ottimizzare JAVA e PHP su un'architettura Raspberry Pi...
Come l’Open Source può essere alla base di un business di successo: il caso H...
OrientDB & Big Data
Applicazioni HTML5 Superveloci - Salvatore Romeo
VMUGIT - Virtualizzare con i piedi per terra

Similar to Esempio di architettura distribuita basata su PHP, CouchDB e Mobile (20)

PDF
Presentazione al VMUGIT UC 2014 - Virtualizzare con i piedi per terra
PPTX
Introduzione a Drupal 7 - 14/03/2013
PDF
MySQL Tech Tour 2015 - Soluzioni di alta disponibilità con MySQL
PPTX
Microservices webinar EMEA Aug. 2017
PPTX
Realizzazione di Microservizi con Docker, Kubernetes, Kafka e Mongodb
PPTX
Creare un Information Radiator con Delphi
PDF
VMUG.IT @ ITway Campus 2014
ODP
Lezioni 2009
PPTX
Windows 10 for fun - Building an Arcade BarTop
PPTX
CCI2019 - SQL Server ed Azure: Disaster Recovery per tutti
ODP
Matteo Baccan - Valerio Tognozzi - Novara LinuxDay 2015
PPTX
ASP.NET Core 1.0
PDF
Web 2.0 sviluppare e ottimizzare oggi
PDF
Sotto il letto, sopra il cloud: costruirsi un’infrastruttura da zero
PDF
JBoss Data Grid Tech Lab
PDF
Infinispan codemotion - Codemotion Rome 2015
PDF
VMUGIT UC 2013 - 09b VMUGIT SMB
PPTX
SQL Saturday 871 - Sardegna 2019 - SQL Server DR on Azure
PDF
Bbox
PDF
Introduzione alla localizzazione web
Presentazione al VMUGIT UC 2014 - Virtualizzare con i piedi per terra
Introduzione a Drupal 7 - 14/03/2013
MySQL Tech Tour 2015 - Soluzioni di alta disponibilità con MySQL
Microservices webinar EMEA Aug. 2017
Realizzazione di Microservizi con Docker, Kubernetes, Kafka e Mongodb
Creare un Information Radiator con Delphi
VMUG.IT @ ITway Campus 2014
Lezioni 2009
Windows 10 for fun - Building an Arcade BarTop
CCI2019 - SQL Server ed Azure: Disaster Recovery per tutti
Matteo Baccan - Valerio Tognozzi - Novara LinuxDay 2015
ASP.NET Core 1.0
Web 2.0 sviluppare e ottimizzare oggi
Sotto il letto, sopra il cloud: costruirsi un’infrastruttura da zero
JBoss Data Grid Tech Lab
Infinispan codemotion - Codemotion Rome 2015
VMUGIT UC 2013 - 09b VMUGIT SMB
SQL Saturday 871 - Sardegna 2019 - SQL Server DR on Azure
Bbox
Introduzione alla localizzazione web
Ad

More from Steve Maraspin (20)

PDF
Architetture a Microservizi (con Kubernetes)
PDF
How Agile changed Software Development
PDF
Principi di Interaction Design
PDF
Customer Journey Mapping Workshop
PDF
A (really) Quick Introduction to Event Storming
PDF
Meet a parallel, asynchronous PHP world
PDF
Don't Make Me Think - There's no need (2014)
PDF
The Metaphor Fallacy (in Digital Product Development)
PDF
Lean UX: Sviluppo Software Agile e Incentrato sull'Utente
PDF
La filosofia Lean nello sviluppo di prodotti digitali
PDF
Error Reporting in ZF2: form messages, custom error pages, logging
PDF
Outcome not Output: A Story of Lean UX Adoption
PDF
Don't Make me Think - There's no Need
PDF
ZF2 Modular Architecture - Taking advantage of it
PDF
Fare con Zend Framework 2 ciò che facevo con ZF1
PDF
NoSQL Data Stores: Introduzione alle Basi di Dati Non Relazionali
PDF
NoSQL, No Worries: Vecchi Problemi, Nuove Soluzioni
PDF
Permettere al cliente di apprezzare l'approccio agile
PDF
Let customers appreciate the agile workflow
PDF
Striving towards better PHP code
Architetture a Microservizi (con Kubernetes)
How Agile changed Software Development
Principi di Interaction Design
Customer Journey Mapping Workshop
A (really) Quick Introduction to Event Storming
Meet a parallel, asynchronous PHP world
Don't Make Me Think - There's no need (2014)
The Metaphor Fallacy (in Digital Product Development)
Lean UX: Sviluppo Software Agile e Incentrato sull'Utente
La filosofia Lean nello sviluppo di prodotti digitali
Error Reporting in ZF2: form messages, custom error pages, logging
Outcome not Output: A Story of Lean UX Adoption
Don't Make me Think - There's no Need
ZF2 Modular Architecture - Taking advantage of it
Fare con Zend Framework 2 ciò che facevo con ZF1
NoSQL Data Stores: Introduzione alle Basi di Dati Non Relazionali
NoSQL, No Worries: Vecchi Problemi, Nuove Soluzioni
Permettere al cliente di apprezzare l'approccio agile
Let customers appreciate the agile workflow
Striving towards better PHP code
Ad

Esempio di architettura distribuita basata su PHP, CouchDB e Mobile