Mongo DB

252 views
207 views

Published on

Александр Колесень «Mongo DB»

Доклдад на майской линуксовке MLUG 2013

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

  • Be the first to like this

No Downloads
Views
Total views
252
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
1
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Mongo DB

  1. 1. Hello
  2. 2. MongoDB • open-source • document-oriented • json/bson
  3. 3. JSON > db.users.findOne() { "_id" : ObjectId("5099803df3f4948bd2f98391"), "name" : { "first" : "Alan", "last" : "Turing" }, "birth" : ISODate("1912-06-22T21:00:00Z"), "death" : ISODate("1954-06-06T21:00:00Z"), "views" : NumberLong(1250000) }
  4. 4. _id field > db.users.findOne({}, {_id: 1, name: 1}) { "_id" : ObjectId("5099803df3f4948bd2f98391"), "name" : { "first" : "Alan", "last" : "Turing" } } > ObjectId("509..91").getTimestamp() ISODate("2012-11-06T21:25:17Z")
  5. 5. BSON • http://bsonspec.org/#/specification • http://groups.google.com/group/bson
  6. 6. Schemaless > db.users.update({_id: ObjectId("509..91")}, { $set: { born: "London, England" }}) > db.users.find({"name.first": "Alan"}) { "_id" : ObjectId("5099803df3f4948bd2f98391"), "birth" : ISODate("1912-06-22T21:00:00Z"), "born" : "London, England", "death" : ISODate("1954-06-06T21:00:00Z"), "name" : { "first" : "Alan", "last" : "Turing" }, "views" : NumberLong(1250000) }
  7. 7. Storage • mmap • OS page cache
  8. 8. Journal • present • group commit every 100ms, by default (2..300ms)
  9. 9. Fault-tolerance PRIMARY> rs.conf() { "_id" : "rs2", "version" : 3, "members" : [ { "_id" : 0, "host" : "10.99.41.134:27017" }, { "_id" : 1, "host" : "10.28.130.177:27017" }, { "_id" : 2, "host" : "10.217.30.225:27017" } ] }
  10. 10. Sharding • horizontal partitioning • multiple nodes • ‘config‘ servers, 1 or 3, sync. replication • ‘mongos‘ routers • db.runCommand(addshard: ... ) • db.runCommand(removeshard: ... ) • chunks, 64M, changeable • do it once, do it right • increasing monotonically • so do not shard by _id
  11. 11. Locks, etc. • server-wide lock, prior to 2.1 • DB-level lock now • yield on page fault • ext3 fallocate, slow
  12. 12. Coursera “Functional Programming Principles in Scala” by Martin Odersky https://class.coursera.org/progfun-002/class/index

×