Hey. I’ve been developing my app for a couple of months now and I’ve just recently been accepted to the App Store and google play store. Hooray!
However, for the last couple of days I’ve been worried about scaling and how my app will preform under load, with potentially (and hopefully) hundreds and thousands of users.
Rather than shrug it off and “worry about it later”, I’d like to address it now while there’s not as much data in my database.
Essentially I have one quick question in particular, but if anyone could give me some other tips on how to optimise my database for scaling in the future, that would be great too.
My question is this. Right now my app has a group messaging feature. Each group is characterised by its _id that mongo automatically generates when a group is created. Every group is stored in a single collection named “groups”, and every message is stored in a single collection called messages.
In node I have an endpoint that gets all the messages from a given group._id, the way it works is in the individual message’s body, I have a “groupId:” field that contains the group._id that the message was sent from.
However I’m wondering if rather than filtering potentially millions of messages and finding the ones with the given groupId, should I instead create a new collection every time a group is created? Would it be faster to have thousands of collections and instantly return those, without any filter delay. Or filter between millions based on a given groupId in a single collection housing all the messages ever sent in the app. Is there any downside to having too many collections ?
Hope I explained clearly.
Thanks guys !