Your SlideShare is downloading. ×
2010-08-26-mongodb-step-by-step-by-hexnova
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

2010-08-26-mongodb-step-by-step-by-hexnova

2,819
views

Published on

A lecture about the way to deep inside mongodb. …

A lecture about the way to deep inside mongodb.
2010-08-26 shanghai


0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
2,819
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
73
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Step by Step
    {author: “Daisy Li.“, mail: “daisy.li1989@gmail.com”, knowmore: “hexnova.org” }
  • 2. mongoDB
    {name: “mongo”, type: “DB”}
    Got it name from?
    humongous (very big, [= enormous])
    Document-oriented storage ?
    JSON-style documents.(BSON)
    Dynamic schemas.
    Scalable, High availability.
    mongos: automatic sharding
    replica set: automatic failover
    Open source
    GNU Affero General Public License
    Full Index Support
    Compound Keys Indexes
    Background Index Building
  • 3. Learn mongoDB
    Try mongoDB
    Use mongoDB
    Your mongoDB
  • 4. Try mongoDB: A Simple Way
    Using Tiny mongoDB Brower Shell
    Visit www.mongodb.org => TRY IT OUT
  • 5. Try mongoDB: Shell Example
    MongoDB browser shell version: 0.1.0
    connecting to random database
    type "help" for help
    type "tutorial" to start the tutorial
    > a = {name: "mongo", type: "DB"}
    { "name" : "mongo", "type" : "DB" }
    > db.mycollection.save(a);
    "ok"
    > db.mycollection.update({name: "mongo"}, {$set: {license: "AGPL"}});
    "ok"
    > db.mycollection.find();[   {   "name" : "mongo",   "license" : "AGPL",   "type" : "DB",   "_id" : {   "$oid" : "4c665f61cc937415bd001308"   }   }]
    >
  • 6. Use mongoDB: Strong Side
    Schemaless
    No need to backup SQL script
    Available when started
    Full Index Support
    RDBMS-style indexes
    Background index building
    High Performance
    Cache disk file
  • 7. Use mongoDB: Feature
    Comparatively Consumptive
    Memory (BSON)
    Bandwidth (BSON)
    Disk (BSON)
    No Transaction Support
    Consistency cannot be achieved
    No transaction isolation
  • 8. Use mongoDB: BSON in Brief
    {“hello”: “world”}
    x16x00x00x00  length
    x02  property type
    hellox00  property name
    x06x00x00x00worldx00
     property value
    x00  a EOF
  • 9. Use mongoDB: In mongoDB
    > hexdump –C test.0
    00003610 b4 12 73 64 69 64 00 1a 00 00 00 00 00 00 00 12 |..sdid..........|
    00003620 66 73 64 69 64 00 b0 8a 23 ee f4 5d 10 a2 12 67 |fsdid...#..]...g|
    00003630 72 6f 75 70 49 64 00 e4 4c 6a 09 fe 66 5c 1e 12 |roupId..Lj..f..|
    00003640 63 72 65 61 74 65 54 69 6d 65 00 4c 0f 7d 84 6a |createTime.L.}.j|
    00003650 75 f9 3a 12 6c 61 73 74 4d 6f 64 69 66 79 54 69 |u.:.lastModifyTi|
    00003660 6d 65 00 4b 81 97 39 14 b0 e6 18 10 64 65 6c 46 |me.K..9.....delF|
    00003670 6c 61 67 00 2a d8 25 11 10 67 72 6f 75 70 54 79 |lag.*.%..groupTy|
    00003680 70 65 00 6a 1d fc 3b 00 9c 00 00 00 00 26 00 00 |pe.j..;......&..|
    00003690 24 37 00 00 ec 35 00 00 8c 00 00 00 07 5f 69 64 |$7...5......._id|
    000036a0 00 4c 74 dd 0a a2 77 3d 23 70 c7 3f b4 12 73 64 |.Lt...w=#p.?..sd|
    000036b0 69 64 00 1b 00 00 00 00 00 00 00 12 66 73 64 69 |id..........fsdi|
    000036c0 64 00 32 b0 15 e8 a8 0d 4f 07 12 67 72 6f 75 70 |d.2.....O..group|
    000036d0 49 64 00 e6 2c c8 c0 f6 b2 d4 7f 12 63 72 65 61 |Id..,.......crea|
    000036e0 74 65 54 69 6d 65 00 d9 13 13 e5 98 05 1c 01 12 |teTime..........|
    000036f0 6c 61 73 74 4d 6f 64 69 66 79 54 69 6d 65 00 7d |lastModifyTime.}|
    00003700 07 b9 d0 32 f8 46 f2 10 64 65 6c 46 6c 61 67 00 |...2.F..delFlag.|
    00003710 25 5a 9e 20 10 67 72 6f 75 70 54 79 70 65 00 5e |%Z. .groupType.^|
    00003720 48 ba 3a 00 9c 00 00 00 00 26 00 00 c0 37 00 00 |H.:......&...7..|
    00003730 88 36 00 00 8c 00 00 00 07 5f 69 64 00 4c 74 dd |.6......._id.Lt.|
    00003740 0a a2 77 3d 23 71 c7 3f b4 12 73 64 69 64 00 1c |..w=#q.?..sdid..|
  • 10. Use mongoDB: HA & Scalable
  • 11. Use mongoDB: Attention
    Manipulation result not returned
    Get last error after every operation
    Server-side cursor
    If used, read till the last record of a query result or kill the cursor.
    Take whole control of cursor.
  • 12. Your mongoDB: Capacity Planning
    How about the performance of your server? (memorycpuandwidthdisk…)
    The size of your record? (not your origin object size, but the BSON object size)
    How much records do you want to hold on single server? (now? future?)
    TPS under different operations? (insertselect…)
  • 13. Your mongoDB: Code Tuning
    Learn to use several tools (SConstructVS2010Emacs…).
    Analyze source code.
    Debug it.
    Find the bottleneck and the codes related.
    Modify as less as possible.
    Recompile and retest.
  • 14. Your mongoDB: Amoeba for mongoDB
    mongos’ssharding is based on chunk. A chunk represent a range of records. In most cases, IDs cannot be sharded horizontally in this way.
    8298701
    149809762
    1987093
    0
    4032987
    7298610
    11098726
    DB1
    DB2
    DB3
  • 15. Your mongoDB: Amoeba for mongoDB
    Like Amoeba for MySQL, Amoeba for mongoDB will provide full control of sharding rules.(by hash angefunction… horizontally vertically)
    Better failover. Write multiple copy of data to several nodes. (instead of replication)
  • 16. Step by Step
    Thank you!
    {author: “Daisy Li.“, mail: “daisy.li1989@gmail.com”, knowmore: “hexnova.org” }