I currently have a monolithic web application. Some API calls need a lot of processing resources and I would like to take that part out of my "backend" monolith and put it in its own service.
I use Docker Compose to develop my application. My database is a MongoDB replica set, to simulate what I have in production, which is a 3-nodes replica set on MongoDB Atlas. My containers in development look like this:
I've read about microservices and it seems to be highly recommended that distinct services should not share data. I've never worked with a microservices architecture before, but the arguments for not sharing data made sense, so I intend to follow this advice.
So this would mean that if I split my "backend" in 2 parts, let's call them "backend" and "backend-heavy", each one would need its own database.
In production, on MongoDB Atlas, I will probably spin up another database for "backend-heavy", or even possibly another cluster. Then, I will run my "backend-heavy" service separately from "backend". But now, I'm wondering how my development setup would look like. Would I need "mongo-heavy0", "mongo-heavy1" and "mongo-heavy2" for my "backend-heavy" service, like this?
What if I eventually want to take another part of my backend and make it its own service? Would I need another 3 containers for this third service as well? It doesn't really make sense to me. By the way, the reason I need a replica set in development is because some MongoDB commands, such as transactions, are only available with a replica set. Also, I like having my development setup as close to my production setup as possible.