Try   HackMD

MongoDB Performance
ch5 Performance on Clusters

tags: MongoDB University M201

Performance Considerations in Distributed Systems

  • Distributed System in MongoDB

    • Replica Cluster
    • Shard Cluster
  • Working with Distributed Systems

    • Consider latency
    • Data si spread across different nodes
    • Read implications
    • Write implications

Before Sharding

  • sharding is an horizontal scaling solution
  • Have you reached the limits of our vertical scaling
  • Need to understand how data grows and how data is access
  • Sharding works by defining key base ranges
  • It's important to have a shardkey

Increasing Write Performance with Sharding

  • frequency
  • Rate of change - Avoid monotonically increasing or decreasing values
db.collection.bulkWrite([op1, op2], { order: <bool> })

order: Execute operations one by one if "true" else execute operations in parallel

Reading from Secondaries

When reading from secondary is a good idea

  • Offloading work
  • Local reads

When reading from secondary is a bad idea

  • In general
  • Reading from shard directly

Aggregation Pipeline on a Sharded Cluster