Se ha denunciado esta presentación.
Utilizamos tu perfil de LinkedIn y tus datos de actividad para personalizar los anuncios y mostrarte publicidad más relevante. Puedes cambiar tus preferencias de publicidad en cualquier momento.

A Brief MongoDB Intro

2.292 visualizaciones

Publicado el

A brief mongodb intro

Publicado en: Tecnología
  • Sé el primero en comentar

A Brief MongoDB Intro

  1. 1. MongoDB <ul><li>The Highly Scalable, Enterprise Grade, Open Source Database </li></ul>
  2. 2. NoSQL: A New Era of Databases <ul><li>Big Data, Big Problem </li></ul>Scaling for the Demands of Modern Applications
  3. 3. Starting from Scratch <ul><li>10gen as an open source ‘ app engine ’ cloud platform </li></ul><ul><li>Backend storage needs </li></ul><ul><ul><li>Agility </li></ul></ul><ul><ul><li>Scalability </li></ul></ul><ul><ul><li>Feature-richness </li></ul></ul><ul><ul><li>Performance </li></ul></ul><ul><ul><li>Ease of use </li></ul></ul>
  4. 4. Agility <ul><li>MongoDB is document-oriented. </li></ul><ul><li>JSON-like objects </li></ul><ul><li>‘ Documents ’ are organized into ‘ Collections ’ </li></ul><ul><li>Schema is not enforced </li></ul>> a = { name: “ mongo ” }; { “ name ” : “ mongo ” } >b = { x : 3 }; { “ x ” : 3 } > c = { x : 4 , j : 1 }; { “ x ” : 4 , “ j ” : 1 } >db.things.save(a) >db.things.save(b) >db.things.save(c) >db.things.find() { &quot;_id&quot; : ObjectId(&quot;4c2209f9f3924d31102bd84a&quot;), &quot;name&quot; : &quot;mongo&quot; } { &quot;_id&quot; : ObjectId(&quot;4c2209fef3924d31102bd84b&quot;), &quot;x&quot; : 3 } { &quot;_id&quot; : ObjectId(&quot;4c220a42f3924d31102bd856&quot;), &quot;x&quot; : 4, &quot;j&quot; : 1 }
  5. 5. Deep Data <ul><ul><li>{ _id : ObjectId(&quot;4c4ba5c0672c685e5e8aabf3&quot;), </li></ul></ul><ul><ul><li>author : ” roger&quot;, </li></ul></ul><ul><ul><li>date : &quot;Sat Jul 24 2010 19:47:11 GMT-0700 (PDT)&quot;, </li></ul></ul><ul><ul><li>text : &quot; I love J.Biebs... &quot;, </li></ul></ul><ul><ul><li>tags : [ ” rockstar&quot;, ” puppy-love&quot; ], </li></ul></ul><ul><ul><li>comments_count: 1, </li></ul></ul><ul><ul><li>comments : [ </li></ul></ul><ul><ul><li>{ </li></ul></ul><ul><ul><li>author : ” Gretchen&quot;, </li></ul></ul><ul><ul><li>date : &quot;Sat Jul 24 2010 20:51:03 GMT-0700 (PDT)&quot;, </li></ul></ul><ul><ul><li>text : ” Biebs is Toll!!!!&quot; </li></ul></ul><ul><ul><li>} </li></ul></ul><ul><ul><li>]} </li></ul></ul>
  6. 6. Replication <ul><li>Replication for high availability </li></ul><ul><li>Replica Sets </li></ul><ul><ul><li>Auto-failover </li></ul></ul><ul><ul><li>Primary fails, secondary elected primary </li></ul></ul><ul><ul><li>Primary repaired, becomes secondary </li></ul></ul><ul><li>Single-write node </li></ul><ul><li>Great for higher read volume </li></ul>
  7. 7. Replication Primary Secondary Secondary Secondary Secondary Client
  8. 8. Scalability <ul><li>MongoDB features autosharding for horizontal scalability </li></ul>mongod mongod mongod mongos mongod mongod mongod Config Servers Shard Shard Shard Client
  9. 9. Sharding with Replica Sets mongod mongos mongod mongod mongod Config Servers Shard Shard Shard mongod mongod mongod mongod mongod mongod mongod mongod Client
  10. 10. Performance <ul><li>Data Model </li></ul><ul><ul><li>Dynamic </li></ul></ul><ul><ul><li>Deep data </li></ul></ul><ul><li>In-place updates </li></ul><ul><li>Simplicity </li></ul>
  11. 11. Performance <ul><li>milancermak.posterous.com </li></ul>
  12. 12. Performance <ul><li>MongoDB test results: </li></ul><ul><li>siege -f ./stress_urls.txt -c 300 -r 10 -d1 -i </li></ul><ul><li>Transactions: 2994 hits </li></ul><ul><li>Availability: 99.80 % </li></ul><ul><li>Elapsed time: 11.95 secs </li></ul><ul><li>Data transferred: 3.19 MB </li></ul><ul><li>Response time: 0.26 secs </li></ul><ul><li>Transaction rate: 250.54 trans/sec </li></ul><ul><li>Throughput: 0.27 MB/sec </li></ul><ul><li>Concurrency: 65.03 </li></ul><ul><li>Successful transactions: 2994 </li></ul><ul><li>Failed transactions: 6 </li></ul><ul><li>Longest transaction: 1.47 </li></ul><ul><li>Shortest transaction: 0.00 </li></ul><ul><ul><ul><ul><ul><li>MySQL test results: </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>siege -f ./stress_urls_mysql.txt -c 300 -r 10 -d1 -i </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>Transactions: 2832 hits </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>Availability: 94.40 % </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>Elapsed time: 23.53 secs </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>Data transferred: 2.59 MB </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>Response time: 0.74 secs </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>Transaction rate: 120.36 trans/sec </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>Throughput: 0.11 MB/sec </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>Concurrency: 89.43 </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>Successful transactions: 2832 </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>Failed transactions: 168 </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>Longest transaction: 16.36 </li></ul></ul></ul></ul></ul><ul><ul><ul><ul><ul><li>Shortest transaction: 0.00 </li></ul></ul></ul></ul></ul>obvioushints.blogspot.com
  13. 13. Performance <ul><li>bcbio.wordpress.com </li></ul>
  14. 14. Recent MongoDB Conferences
  15. 15. MongoDB Downloads
  16. 16. Production + Deployments
  17. 17. Thank you @mongodb [email_address] ; adam@10gen.com Mongo France, March 23 MongoSF, May 24 http://www.10gen.com/events http://bit.ly/mongofb Facebook | Twitter | LinkedIn http://linkd.in/joinmongo download at mongodb.org
  18. 18. (SQL vs MongoDB) <ul><li>SQL Statement </li></ul><ul><li>Mongo Query Language Statement </li></ul><ul><li>CREATE TABLE USERS (a Number, b Number) </li></ul><ul><li>implicit; can be done explicitly </li></ul><ul><li>INSERT INTO USERS VALUES(1,1) </li></ul><ul><li>db.users.insert({a:1,b:1}) </li></ul><ul><li>SELECT a,b FROM users </li></ul><ul><li>db.users.find({}, {a:1,b:1}) </li></ul><ul><li>SELECT * FROM users </li></ul><ul><li>db.users.find() </li></ul><ul><li>SELECT * FROM users WHERE age=33 </li></ul><ul><li>db.users.find({age:33}) </li></ul><ul><li>SELECT a,b FROM users WHERE age=33 </li></ul><ul><li>db.users.find({age:33}, {a:1,b:1}) </li></ul><ul><li>SELECT * FROM users WHERE age=33 ORDER BY name </li></ul><ul><li>db.users.find({age:33}).sort({name:1}) </li></ul><ul><li>SELECT * FROM users WHERE age>33 </li></ul><ul><li>db.users.find({'age':{$gt:33}})}) </li></ul><ul><li>SELECT * FROM users WHERE age<33 </li></ul><ul><li>db.users.find({'age':{$lt:33}})}) </li></ul><ul><li>SELECT * FROM users WHERE name LIKE &quot;%Joe%&quot; </li></ul><ul><li>db.users.find({name:/Joe/}) </li></ul><ul><li>SELECT * FROM users WHERE name LIKE &quot;Joe%&quot; </li></ul><ul><li>db.users.find({name:/^Joe/}) </li></ul>CREATE INDEX myindexname ON users(name,ts DESC) db.users.ensureIndex({name:1,ts:-1}) SELECT * FROM users WHERE a=1 and b='q' db.users.find({a:1,b:'q'}) SELECT * FROM users LIMIT 10 SKIP 20 db.users.find().limit(10).skip(20) SELECT * FROM users WHERE a=1 or b=2 db.users.find( { $or : [ { a : 1 } , { b : 2 } ] } ) SELECT * FROM users LIMIT 1 db.users.findOne() EXPLAIN SELECT * FROM users WHERE z=3 db.users.find({z:3}).explain() SELECT DISTINCT last_name FROM users db.users.distinct('last_name') SELECT COUNT(*y) FROM users db.users.count() SELECT COUNT(*y) FROM users where AGE > 30 db.users.find({age: {'$gt': 30}}).count()

×