MongoDB performance tuning
You find slow operations with the profiler, explain and server metrics and speed MongoDB up for the workload with index, query, schema and WiredTiger cache tuning.
Level 401 · 15 lessons · 12 practice labs
Lessons
Diagnosis
- Performance method and baseline
- Profiler levels and analysis
- Reading explain executionStats
- Query shape statistics
- Short task: classify the ten slowest operations
Improvement
- Selectivity and index order
- Covered queries
- Multikey and wildcard indexes
- The plan cache and hint
- Write performance: bulk writes and write concern
- Short task: clean up unnecessary indexes
Server
- The WiredTiger cache
- Connection pools
- Compression and storage settings
- Capstone: get ready for campaign traffic
Practice labs
- Record a performance baseline: Run a short script that records operation count, latency and cache use under normal load.
- Group profiler data by query shape: Group system.profile entries by query shape and pick the five most expensive by total time.
- Classify the ten slowest operations: Sort the ten slowest operations into missing index, bad query and resource shortage and propose a fix for each.
- Create a covered query: Match the projection to an index so totalDocsExamined drops to zero.
- Fix a query that picks the wrong plan: Detect a bad cached plan, rework the indexes and get the right plan chosen without a hint.
- Design a wildcard index for flexible fields: Replace several indexes with a wildcard index on a collection with user-defined fields and measure write cost.
- Turn single writes into bulk writes: Rewrite a script that inserts 10,000 records one by one with bulkWrite and compare the time.
- Measure the speed cost of write concern: Run the same load with w:1, w:majority and journaled writes and show the latency versus safety trade-off.
- Cut the write cost of excess indexes: Remove needless indexes from a collection whose write latency rose before a campaign and measure the capacity gain.
- Read WiredTiger cache fill: Read cache size, dirty page ratio and eviction count from serverStatus.
- Size the connection pool correctly: Measure connections opened by many app instances and fix pool settings to fit the server's limit.
- Get ready for campaign traffic: Find the bottleneck with a five-times load test and tune cache, compression and indexes to meet the latency target.
About this course
You find slow operations with the profiler, explain and server metrics and speed MongoDB up for the workload with index, query, schema and WiredTiger cache tuning.
What you will learn
- Diagnosis
- Improvement
- Server
Prerequisites
You should have practised the topics of the same path up to level 301.
Lab environment
Lessons run in your own Kali Linux terminal in the browser, connected to a private lab network. Nothing to install.
Frequently asked questions
- Is this course right for my level?
- The course is at level 401; it assumes you know the topics of the lower-level courses.
- Is there anything to install?
- No. Every lesson runs in your own lab environment that opens in the browser.
- How do lessons work?
- Each lesson has 8 to 10 steps and a short quiz. Early steps show the command to type, later steps give less help; if two attempts fail, the solution opens.
- Can I try it for free?
- Yes. The first three lessons of every course are free.