Zum Inhalt springen

Plan your instance

Diese Seite ist noch nicht in deiner Sprache verfügbar. Englische Seite aufrufen

STACKIT offers maximum flexibility in conjunction with MongoDB. However, technical limitations require certain restrictions. To avoid technical debt, downtimes and unwanted future migration, it is best practice to plan your MongoDB Flex instance in advance.

Before selecting your MongoDB Flex instance size, you need to analyze your data patterns and requirements:

Start by estimating your current and projected data size. Consider document size, number of collections, and growth rate over the next 12-24 months. MongoDB Flex stores data in BSON format, which can be 10-15% larger than JSON, so factor this into your calculations. As a rule of thumb, calculate with a factor of 2 to 2.5 for data growth in the next two years.

Examine how your application interacts with the database. Frequent complex queries, aggregations, and index-heavy operations require more CPU and memory resources. Applications with high read-to-write ratios may benefit from different sizing strategies than write-heavy workloads. Also consider if your application is more read or write heavy.

You can consult Architecture of MongoDB Flex for the limitations in flexibility. For a quick reference, you can consult this table:

ParameterDowngrade possibleUpgrade possibleDowntime
typenot applicable
flavorxxx
performance-classx (except single-instance)x (except single-instance)x
storage-sizex
versionxx

You can make changes to ACL and backup settings without any limitations and without downtime.

You need to keep the limitations in mind. This paragraph helps you to make good assumptions and choices to set up an instance.

If you plan to set up an instance for production use, you need to distinguish between a Replica and a Sharded instance type. For most cases Replica is the better option. In the following cases may consider using a Sharded instance:

  • Compliance requirements (EU-users remain in the EU etc.)
  • Data that needs to be accessed from several regions
  • Single server storage limitations (multi-TB datasets)
  • Working set doesn’t fit in RAM of single machine
  • Index size exceeds single server capacity

Read & write scalability: Distribute read and write on multiple servers (only possible when operations are independent from other shards)

Sharding (except geographical sharding) should be the last ressort, first try to achieve the goals with replica sets, indexing and vertical scaling.

  • Adds complexity
  • Decreases performance on queries which depend on multiple shards

At first you need to distinguish if short downtimes are acceptable. If yes, you can start with a small flavor and upgrade it, when you consistently reach 80% of either CPU or RAM consumption. If downtime isn’t acceptable, you need to estimate your needs.

As a rule of thumb you may use this ruleset:

  • Read-heavy: 2-4 CPUs sufficient
  • Write-heavy or aggregations: 8+ CPUs
  • Sharded clusters: Extra CPUs for mongos router
  • Minimum: 25% of data size + index size
  • Optimal: 50-75% of active data size + index size
  • Rule of thumb: 8GB RAM at minimum, better 32GB+ for production

For the performance class you need to distinguish as well if short downtimes are acceptable. If not, you need to estimate your needs.

As a rule of thumb, you may use this ruleset:

  • Read-heavy: 1000-3000 IOPS
  • Write-heavy: 3000-10000+ IOPS
  • Mixed workload: 2000-5000 IOPS

As storage size can be enlarged anytime without downtime, it is safe to start with a smaller size. As a rule of thumb, start with your data size multiplied by 1.3 for the index and multiplied by 3 again for the growth factor.

Start with the highest version your client applications support.