All Collections
Serverless
Keep Atlas serverless instance costs down
Keep Atlas serverless instance costs down
Kabir Ghai avatar
Written by Kabir Ghai
Updated over a week ago

Unlike our traditional clusters, serverless instances offer a fundamentally different pricing model that is primarily metered on reads, writes, and storage with automatic tiered discounts on reads as your usage scales.

Serverless instances are generally most cost effective when used for applications with low or intermittent traffic. Beyond that, the two most important areas to focus if you're looking to use serverless insances to keep costs low is your data model and creating indexes for commonly run queries.


โ€‹

Data modeling

When it comes to data modeling and schema design in MongoDB you should always remember that data that is accessed together, should be stored together. Make use of MongoDB's rich document model to ensure that data can be accessed in a single read operation where possible. In most situations where reads are higher than writes, duplicating data across multiple documents will be much more performant and thus cheaper than storing the data normalized in a separate collection and using the $lookup aggregation stage to query it.

We have a variety of resources that can help you learn to model your data in a more efficient manner following MongoDB design patterns.

Indexes

Indexes support the efficient execution of queries in MongoDB. Without indexes, MongoDB must perform a collection scan, i.e. scan every document in a collection, to select those documents that match the query statement. If an appropriate index exists for a query, MongoDB can use the index to limit the number of documents it must inspect. By adding indexes to common queries you can help lower your read and write counts and in turn your overall costs, and even improve your query performance. To learn more about indexing your data, we recommend you check out these resources:

Atlas also offers built-in tools, like the Performance Advisor which monitors your queries and automatically suggests new indexes to improve query performance. We recommend checking it from time to time to see if we've identified any indexes you could create.

Did this answer your question?