mongoDB Performance

  • 1,767 views
Uploaded on

 

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
No Downloads

Views

Total Views
1,767
On Slideshare
0
From Embeds
0
Number of Embeds
36

Actions

Shares
Downloads
0
Comments
2
Likes
2

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. The VP R&D Open SeminarMongoDB PerformanceMoshe Kaplanmokplan@gmail.comhttp://blogs.microsoft.co.il/blogs/vprndhttp://top-performance.blogspot.com
  • 2. http://blogs.microsoft.co.il/blogs/vprndhttp://top-performance.blogspot.comWho is Using MongoDB?2
  • 3. http://blogs.microsoft.co.il/blogs/vprndhttp://top-performance.blogspot.comWho is Behind MongoDB?3
  • 4. http://blogs.microsoft.co.il/blogs/vprndhttp://top-performance.blogspot.com4Strategy A - Sharding
  • 5. http://blogs.microsoft.co.il/blogs/vprndhttp://top-performance.blogspot.com5Strategy B - In Memory Databases
  • 6. http://blogs.microsoft.co.il/blogs/vprndhttp://top-performance.blogspot.com6700 Inserts/SecIn Memory Engine3000 Inserts/SecInnoDB Engine700 Inserts/SecAmazonAWSStandardLargeInstance
  • 7. http://blogs.microsoft.co.il/blogs/vprndhttp://top-performance.blogspot.com7Strategy C – MapReducehttp://blogs.microsoft.co.il/blogs/vprnd
  • 8. http://blogs.microsoft.co.il/blogs/vprndhttp://top-performance.blogspot.comStrategy D - NoSQLinsertgetmultigetremovetruncate8<Key, Value>http://wiki.apache.org/cassandra/API
  • 9. http://blogs.microsoft.co.il/blogs/vprndhttp://top-performance.blogspot.com9And now…http://www.webperformancetoday.com/2010/06/15/everything-you-wanted-to-know-about-web-performance/
  • 10. http://blogs.microsoft.co.il/blogs/vprndhttp://top-performance.blogspot.comThe VP R&D Open SeminarMONGODB TUNING10
  • 11. http://blogs.microsoft.co.il/blogs/vprndhttp://top-performance.blogspot.comjournalCommitInterval = 300:Write to disk: 2ms <= t <= 300msDefault 100ms, increase to 300ms to saveresourcesDiskThe Journal11MemoryJournal Data1 2
  • 12. http://blogs.microsoft.co.il/blogs/vprndhttp://top-performance.blogspot.commongod.conf TuningmaxConns: # of connection (<20,000)objcheck: BSON validation. false to saveoverhead.nohttpinterface = true: disables http interfacenoprealloc = false: preallocates space @ startupnoscripting = true: disables scripting engineprofile = 0: disable profilingrest = false: disable REST service12
  • 13. http://blogs.microsoft.co.il/blogs/vprndhttp://top-performance.blogspot.comThe VP R&D Open SeminarSERVER STATS13
  • 14. http://blogs.microsoft.co.il/blogs/vprndhttp://top-performance.blogspot.comWhat we are facing of?> db.serverStatus().mem;> db.serverStatus().extra_info;> db.serverStatus().globalLock;> db.serverStatus().backgroundFlushing;> db.serverStatus().connections;> db.serverStatus().network;14RAMPage FaultsLock RatioI/O SpeedNot Too ManyBandwidth
  • 15. http://blogs.microsoft.co.il/blogs/vprndhttp://top-performance.blogspot.comRAM OptimizationdataSize + indexSize < RAM15OSData IndexJournal
  • 16. http://blogs.microsoft.co.il/blogs/vprndhttp://top-performance.blogspot.comThe VP R&D Open SeminarPROFILING AND SLOW LOG16
  • 17. http://blogs.microsoft.co.il/blogs/vprndhttp://top-performance.blogspot.comProfiling ConfigurationEnable:• mongod --profile=1 --slowms=15• db.setProfilingLevel([level] , [time])How much:• 0 (none) 1 (slow queries only) 2 (all)• 100ms: defaultWhere:• system.profile collection17
  • 18. http://blogs.microsoft.co.il/blogs/vprndhttp://top-performance.blogspot.comProfiling Results AnalysisLast 5 >1ms: show profilew/o commands:db.system.profile.find( { op: { $ne : command } } ).pretty()Specific database:db.system.profile.find( { ns : mydb.test } ).pretty()Slower than:db.system.profile.find( { millis : { $gt : 5 } } ).pretty()Between dates:db.system.profile.find({ts : {$gt : new ISODate("2012-12-09T03:00:00Z") ,$lt : new ISODate("2012-12-09T03:40:00Z")}}).pretty()18
  • 19. http://blogs.microsoft.co.il/blogs/vprndhttp://top-performance.blogspot.comExplain> db.courses.find().explain();{ "cursor" : "BasicCursor","isMultiKey" : false,"n" : 11, “nscannedObjects" : 11,"nscanned" : 11, "nscannedObjectsAllPlans" : 11,"nscannedAllPlans" : 11,"scanAndOrder" : false, "indexOnly" : false,"nYields" : 0,"nChunkSkips" : 0,"millis" : 0,"indexBounds" : {},"server" : "primary.domain.com:27017"}19
  • 20. http://blogs.microsoft.co.il/blogs/vprndhttp://top-performance.blogspot.comThe VP R&D Open SeminarINDEXES20
  • 21. http://blogs.microsoft.co.il/blogs/vprndhttp://top-performance.blogspot.comIndex ManagementRegular Indexdb.users.ensureIndex( { user_id: 1 } )Multiple + DESC Indexdb.users.ensureIndex( { user_id: 1, age: -1 } )Sub Document Indexdb.users.ensureIndex( { address.zipcode: 1 } )List Indexesdb.users.getIndexes()Drop Indexesdb.users.dropIndex(“indexName”)21
  • 22. http://blogs.microsoft.co.il/blogs/vprndhttp://top-performance.blogspot.comKnown Index IssuesBound filter should be the last(in the index as well).22
  • 23. http://blogs.microsoft.co.il/blogs/vprndhttp://top-performance.blogspot.comThe VP R&D Open SeminarSTATS &SCHEMA DESIGN23
  • 24. http://blogs.microsoft.co.il/blogs/vprndhttp://top-performance.blogspot.comSparse Matrix? I don’t Think somongostat> db.stats();> db.collectionname.stats();Fragmentation if storageSize/size > 2db.collectionanme.runCommand(“compact”)Padding (wrong design) if paddingFactor > 224
  • 25. http://blogs.microsoft.co.il/blogs/vprndhttp://top-performance.blogspot.comThe VP R&D Open SeminarTHE LOCKING DILEMA25
  • 26. http://blogs.microsoft.co.il/blogs/vprndhttp://top-performance.blogspot.comLocking on Write (CRUD)2.0 Global Lock2.2 Database Lock2.X …What to do till then?26
  • 27. http://blogs.microsoft.co.il/blogs/vprndhttp://top-performance.blogspot.comThe Startup Nation Feed27 Join @ InsideMy.co