Torino, 11 luglio 2011NoSQLPHP.TO.START  David Funaro
What about me ?• sw engineer• PHP developer (2002)• Symfony Framework developer (2009)• Mobile developer ( iOs / Symbian )...
Database - logical model                      Other      RDBMS              NOSQL
Relational DB•   In the *70’s•   SQL ,relational algebra & set theory•   excellent for applications such as management    ...
ACIDTransactions work in the right mode if thedatabase can satisfy this four properties:   • Atomic   • Consistency   • Is...
Database - logical model                      Other      RDBMS              NOSQL
Database - logical model
Database - logical model           Document           Oriented                       Column    Key                Oriented...
NOSql !=
NOSql !=One Size fits allNot Only Sql
Historical IntroThe concept of “non relational database” isolder than the “relational model” but has beenresumed and impro...
New Requirements
New Requirementshalf *90’s
New Requirementshalf *90’swith the new internet-based systems theConsistency and the Security of data are nolonger enough
New Requirementshalf *90’swith the new internet-based systems theConsistency and the Security of data are nolonger enought...
Google• distributed storage system• scale file dimension up to Petabyte          Wide applicability              Scalabilit...
Google BigTable                   column - Oriented DB• Web indexing• Google Earth• Google Finance• Orkut• Custom Search• ...
Amazon• Relational model doesn’t fit requirements• 10 of thousand of server around the world• 10 Millions customers        ...
Amazon Dynamo                     Key-Value Store Database• High Reliability• High Scale
New Trends
Web Company•       Startup with explosive growth:    •     DBMS open source    •     v 1.0 - 1 node , becomes soon inadequ...
Web Company•   Re-implement inter-node query•   Handle inter-node transaction•   Node failure increasingly likely - less r...
Solution•   Scalability, very simple operations,                                           }    but on many nodes•   Perfo...
Compromise• SQL Renounce• less strict transactions
Query LanguageLeave a standard query language like SQL, andembrace a different kind of query language basedon the selected...
CAP Theorem(2009) • Consistency • Availability • Partition Tollerance             Eric BrewerIt’s impossibile to have all ...
Consistency•   Strong: After the update completes any    subsequent access will return the updated                        ...
Consistency•   Strong: After the update completes any    subsequent access will return the updated                        ...
Facebook Cassandra• Key-Value store• data model: BigTable• infrastructure: Amazon-Dynamo• Eventual Consistency• High Avail...
Search Best Solution  Just find the right way to    manage your data-set
contextpurpose                         Technology FocusCost of implementation
choose bike => (climb the mountain)
choose bike => (climb the mountain)
choose bike => (climb the mountain)
choose bike => (climb the mountain)
choose bike => (climb the mountain)       Know available tools
NOSql Families
Key Value StoreOne Key -> One Valueit’s like an HASHdb knows information about “key” type(integer, float, ...), nothing abo...
Key Value Storeperformance        high Scalability       high                                • redis                      ...
Document Oriented• key -> document• structured document• schema-less        {                         name: ‘david’,      ...
Document Orientedperformance         high Scalability   variable (high) Flexibility        highComplexity          lowFunc...
Graph DB• composed by Vertices and Edges• Vertices connected by Edges• Edge has a Label and Direction• Edges and Vertices ...
Graph DB           Funaro                  surname David           na                                    User_2           ...
Graph DBperformance       variable Scalability      variable     • neo4J Flexibility        high                          ...
Why NOSql    some case example
A Graph RDBMS    Users         Followeeid name salary    id_1 id_2                   2    41   ale     200                ...
A Graph RDBMS    Users         Followeeid name salary    id_1 id_2                   2    4     handled as BTree1011   ale...
A Graph RDBMS     Lookup david’s id [Log(N)]     N = # users     Look K Followees [Log(N)]     Get their names [K*Log(N)]
Graph DB                 MarcoSergio                      Lookup David Log(N)         David                            Loo...
BenchmarkDeph RDBMS       Graph 1    100ms       30ms                   •     1 Million Vertex 2   1000ms      500ms      ...
Schema             RDBMS                               NOSql - DocumentaleCREATE TABLE `pma_bookmark` (   `id` int(11) NOT...
Schema 2id       name       surname    mobile           url          ...   telex          office        telex     ...1     ...
Schema less• flexibility to handle the data model fields• the model can grow easily
Performance                    ====== SET ======                    100007 requests completed in 0.88 seconds             ...
NOSql for PHP✓Redis✓MongoDB✓CouchDB✓Cassandra✓Memcached✴OrientDB
OrientDB library forPHP      https://github.com/congow/Orient   A Set of tools to use and manage any OrientDB   instance f...
Thanks• David Funaro• http://davidfunaro.com• @ingdavidino• ing.davidino@gmail.com
creditshttp://www.slideshare.net/ClaudioMartella/presentation-7398682?from=ss_embed http://www.slideshare.net/harrikauhane...
Upcoming SlideShare
Loading in...5
×

NoSQL overview #phptostart turin 11.07.2011

4,272

Published on

overview of noslq database

Published in: Technology
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
4,272
On Slideshare
0
From Embeds
0
Number of Embeds
5
Actions
Shares
0
Downloads
46
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

NoSQL overview #phptostart turin 11.07.2011

  1. 1. Torino, 11 luglio 2011NoSQLPHP.TO.START David Funaro
  2. 2. What about me ?• sw engineer• PHP developer (2002)• Symfony Framework developer (2009)• Mobile developer ( iOs / Symbian )• Senior developer @ dnsee• PHP user group Rome Founder• Open Source contributor
  3. 3. Database - logical model Other RDBMS NOSQL
  4. 4. Relational DB• In the *70’s• SQL ,relational algebra & set theory• excellent for applications such as management ( accounting, reservations, management staff)
  5. 5. ACIDTransactions work in the right mode if thedatabase can satisfy this four properties: • Atomic • Consistency • Isolation • Durability
  6. 6. Database - logical model Other RDBMS NOSQL
  7. 7. Database - logical model
  8. 8. Database - logical model Document Oriented Column Key Oriented Value Graph DB NOSql
  9. 9. NOSql !=
  10. 10. NOSql !=One Size fits allNot Only Sql
  11. 11. Historical IntroThe concept of “non relational database” isolder than the “relational model” but has beenresumed and improved technology comes back
  12. 12. New Requirements
  13. 13. New Requirementshalf *90’s
  14. 14. New Requirementshalf *90’swith the new internet-based systems theConsistency and the Security of data are nolonger enough
  15. 15. New Requirementshalf *90’swith the new internet-based systems theConsistency and the Security of data are nolonger enoughthe new need is the Hight availability
  16. 16. Google• distributed storage system• scale file dimension up to Petabyte Wide applicability Scalability High performance High availability
  17. 17. Google BigTable column - Oriented DB• Web indexing• Google Earth• Google Finance• Orkut• Custom Search• Google Docs
  18. 18. Amazon• Relational model doesn’t fit requirements• 10 of thousand of server around the world• 10 Millions customers High Reliability High scale
  19. 19. Amazon Dynamo Key-Value Store Database• High Reliability• High Scale
  20. 20. New Trends
  21. 21. Web Company• Startup with explosive growth: • DBMS open source • v 1.0 - 1 node , becomes soon inadequate • next version: • Horizontal Partitioning (sharding) • implement the node routing inside the application logic
  22. 22. Web Company• Re-implement inter-node query• Handle inter-node transaction• Node failure increasingly likely - less reliability - less availability• “Hot” Data restructuring and data redistribuition becomes hard
  23. 23. Solution• Scalability, very simple operations, } but on many nodes• Performance, low latency web• Productivity Application• Flexibility (data structure) needs• Skill to distribute data on many nodes
  24. 24. Compromise• SQL Renounce• less strict transactions
  25. 25. Query LanguageLeave a standard query language like SQL, andembrace a different kind of query language basedon the selected product• SQL like• map-reduce• SparQL• ...
  26. 26. CAP Theorem(2009) • Consistency • Availability • Partition Tollerance Eric BrewerIt’s impossibile to have all of them at the sametime in a distributed system.You have to chooseonly two.
  27. 27. Consistency• Strong: After the update completes any subsequent access will return the updated N1 value.• Weak: The system does not guarantee that subsequent accesses will return the updated N2 value. tk tk• Eventually: The storage system guarantees that N6 if no new updates are made to the object tk eventually (after the inconsistency window tk closes) all accesses will return the last N5 updated value. N4
  28. 28. Consistency• Strong: After the update completes any subsequent access will return the updated N1 value.• Weak: The system does not guarantee that subsequent accesses will return the updated N2 value. tk tk• Eventually: The storage system guarantees that N6 if no new updates are made to the object tk eventually (after the inconsistency window tk closes) all accesses will return the last N5 updated value. N4
  29. 29. Facebook Cassandra• Key-Value store• data model: BigTable• infrastructure: Amazon-Dynamo• Eventual Consistency• High Availability
  30. 30. Search Best Solution Just find the right way to manage your data-set
  31. 31. contextpurpose Technology FocusCost of implementation
  32. 32. choose bike => (climb the mountain)
  33. 33. choose bike => (climb the mountain)
  34. 34. choose bike => (climb the mountain)
  35. 35. choose bike => (climb the mountain)
  36. 36. choose bike => (climb the mountain) Know available tools
  37. 37. NOSql Families
  38. 38. Key Value StoreOne Key -> One Valueit’s like an HASHdb knows information about “key” type(integer, float, ...), nothing about the valuevery fast ‘name’ => ‘david’ key value
  39. 39. Key Value Storeperformance high Scalability high • redis • memcached Flexibility high • dynamoComplexity none • voldemortFunctionality variabile(none)
  40. 40. Document Oriented• key -> document• structured document• schema-less { name: ‘david’, surname: ‘funaro’, age: ’18’, user_13 => mail: { home : ‘ing.davidino@gmail.com’, key office: ‘d.funaro@dnsee.com‘ } } document
  41. 41. Document Orientedperformance high Scalability variable (high) Flexibility highComplexity lowFunctionality variabile(low)
  42. 42. Graph DB• composed by Vertices and Edges• Vertices connected by Edges• Edge has a Label and Direction• Edges and Vertices have Properties
  43. 43. Graph DB Funaro surname David na User_2 me friend User_1dnsee work friend User_3 fri en d User_3
  44. 44. Graph DBperformance variable Scalability variable • neo4J Flexibility high • OrientDBComplexity high • infogrid • VertexDBFunctionality graph theory
  45. 45. Why NOSql some case example
  46. 46. A Graph RDBMS Users Followeeid name salary id_1 id_2 2 41 ale 200 3 12 marco 230 3 43 david 340 3 2 1 54 sergio 349 5 35 andre 200 5 2
  47. 47. A Graph RDBMS Users Followeeid name salary id_1 id_2 2 4 handled as BTree1011 ale 200 3 12 marco 230 3 43 david 340 3 2 1 54 sergio 349 5 35 andre 200 5 2
  48. 48. A Graph RDBMS Lookup david’s id [Log(N)] N = # users Look K Followees [Log(N)] Get their names [K*Log(N)]
  49. 49. Graph DB MarcoSergio Lookup David Log(N) David Lookup for Followees O(K) Andrea Ale
  50. 50. BenchmarkDeph RDBMS Graph 1 100ms 30ms • 1 Million Vertex 2 1000ms 500ms • 4 Million Edge 3 10000ms 3000ms • Scale Free Tolopogy 4 100000ms 50000ms • Postgres VS Neo4J 5 N/A 100000ms • Both Hash and BTree http://markorodriguez.com/2011/02/18/mysql-vs-neo4j-on-a-large-scale-graph-traversal/
  51. 51. Schema RDBMS NOSql - DocumentaleCREATE TABLE `pma_bookmark` ( `id` int(11) NOT NULL auto_increment, `name` varchar(255) NOT NULL default , `surname` varchar(255) NOT NULL default , `mobile` varchar(255) NOT NULL default , `url` text NOT NULL,... `name` varchar(255) NOT NULL default ,... Schema Less `telex` varchar(255) NOT NULL default , `fax` varchar(255) NOT NULL default , `office` text NOT NULL, PRIMARY KEY (`id`));
  52. 52. Schema 2id name surname mobile url ... telex office telex ...1 david funaro 3548 davidfunaro.com null null 3548631 null null2 alessandro nadalin 3257 null null null 32458 5456 null3 marco rossi 3548 null null null null 515648 null too value set to NULL user :{ user :{ user :{ name: david, name: alessandro, name: marco, surname: funaro, surname: nadalin, surname: rossi, mobile : 3454, mobile : 6262, telex: 3434 url: davidfunaro.com, office: 342343, } office: 3423423, telex: 3434 } }Each Document has only the required fields
  53. 53. Schema less• flexibility to handle the data model fields• the model can grow easily
  54. 54. Performance ====== SET ====== 100007 requests completed in 0.88 seconds 50 parallel clients 3 bytes payload keep alive: 1 ====== GET ====== 100000 requests completed in 1.23 seconds 50 parallel clients 3 bytes payload keep alive: 1 http://redis.io/topics/benchmarkshttp://research.yahoo.com/files/ycsb-v4.pdf
  55. 55. NOSql for PHP✓Redis✓MongoDB✓CouchDB✓Cassandra✓Memcached✴OrientDB
  56. 56. OrientDB library forPHP https://github.com/congow/Orient A Set of tools to use and manage any OrientDB instance from PHP. Orient includes: •the HTTP protocol binding •the query builder •the data mapper ( Object Graph Mapper )
  57. 57. Thanks• David Funaro• http://davidfunaro.com• @ingdavidino• ing.davidino@gmail.com
  58. 58. creditshttp://www.slideshare.net/ClaudioMartella/presentation-7398682?from=ss_embed http://www.slideshare.net/harrikauhanen/nosql-3376398 http://www.slideshare.net/ingdavidino/cmf-a-pain-in-the-f-phpday-05142011 http://it.wikipedia.org/wiki/Modello_relazionale http://www.slideshare.net/gabriele.lana/nosql-7405964 http://blog.indigenidigitali.com/l-ecosistema-nosql/ http://www.dia.uniroma3.it/~torlone/bd2/noSQL-1.pdf http://nosql-database.org/
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×