Doucment Write rate to time series collection in Mongo Atlas Free tier Subscription

Hi, Could i know how many documents can be written to a Time Series collection per second, in the Mongo Atlas Free tier subscription?
Could i increase that with InsertMany instead of saving one by one?

1 Like

Hi @Kanishka_Viraj and welcome in the MongoDB Community :muscle: !

You can read more about the limitations of M0, M2 and M5 Cluster Tiers here:

Insertions with an insertMany are always WAY faster than insertOne operations because you reduce dramatically the number of TCP connections. InsertMany is also capable of batching automatically so don’t be scared to insert several thousands documents with a single insertMany operation.

That being said, M0 clusters are limited to 512 MB of disk and the throughput is also limited to 100 operations per seconds… If you are planning something bigger, you will have to upgrade to a higher tier soon :slight_smile: . But thanks to Atlas, you can do that with zero downtime.

Cheers,
Maxime.

2 Likes

Hi , Thank you for the reply,.
I found M0 only allow 100 crud operations per seconds, if i use a insertMany, will it be counted as a 1 crud operation ?

I build a little test to insert 10k docs with an insertMany. If it takes 100 secs to insert the docs, it means it’s 1 doc = 1 operation. If it’s almost instantenous, it means insertMany = 1 operation.

from datetime import datetime
from time import time

from faker import Faker
from pymongo import MongoClient

fake = Faker()


def random_messages():
    docs = []
    for _id in range(1, 10001):
        doc = {
            '_id': _id,
            'user_id': fake.pyint(min_value=1, max_value=100),
            'message': fake.sentence(nb_words=10),
            'date': datetime.strptime(fake.iso8601(), "%Y-%m-%dT%H:%M:%S")
        }
        docs.append(doc)
    return docs


if __name__ == '__main__':
    client = MongoClient('mongodb+srv://max:xap1649zcve@free.ne23r.mongodb.net/test?w=majority')
    db = client.get_database('test')
    messages = db.get_collection('messages')
    messages.drop()
    start = time()
    messages.insert_many(random_messages())
    print('Import done in ', round(time() - start, 2), 's')

Output I get:

Import done in  1.08 s

My conclusion is that insertMany counts as 1 operation as far as I can tell.

But still, M0 clusters are limited to 512 MB of disk and 10GB in & out per 7 days period. M0 clusters are just designed for learning and tests purposes. If you want to run a prod environment, I would run at least an M10 cluster which comes at about $60 per months.

Cheers,
Maxime.

1 Like