Data modelling for a Website Analytics Tool

Hey everyone!

I’m pretty new to MongoDB and back-end programming in general, and I can’t wrap my head around how I should structure this project.

I’m planning to develop a website analytics tool for users to paste a script on their site and then track different metrics about their users. But I’m not sure what’s the best way to structure a database for this that’s able to scale. It needs to be performant if I have 10k+ sites with 1.000.000+ daily visits across all the different sites.

I first thought of creating a collection for each site, with all page visits as single documents inside the collection. But then I read that performance is going down a lot when reaching 10k+ collections.

So I thought to maybe have one collection for all the different sites and one collection for all the page visits. But then I’m not sure if it’ll be a bad performance with potentially many many millions of page visits in the same collection in a few years.

Would love to get some help on how you guys would structure something like this :slight_smile: