What are microservices for?
- Scaling parts of the system independently
- Scaling the engineering team so they can work "independently"
- Keeping a separation of different contexts in DDD
All that comes with costs...
- How do you organize an infrastructure that is auto-scalable, self healing and so on to run this microservices?
- How do you organize an scalable infrastructure for your state storage? (databases, file storage)
- How do you make sure and test that all this tiny pieces are talking to each other in the right and secure way?
- How do you manage all the communication overhead of the team to deal with that kind of architecture?
If you are starting a business forget about microservices, your mayor concern is if there are people there outside willing to pay for your services or product and if you can create a repeatable business case.
Microservices are an optimization and if you do it early you know you are sinning. Do it when you need to, keep them in mind so you can do it later; but not when you don't know if you have to scale.
My only advice on early stage company microservice wise is: make a modular monolith.
- Keep a clear separation of the bounded contexts in some kind of "modules" or whatever the technology you use supports. Always in the beginning of a company the context you are exploring changes a lot but that's fine, starting a company is a discovery journey, embrace it and be flexible.
- Each module should be as full-stack as possible, containing its own piece of front-end, APIs, business logic and persistency layer.
- Don't let modules interact with the internals of other modules, to communicate and pass information between them use APIs, events, smoke signals... I don't care, keep them together but not mixed.
- Dependencies between modules are fine, but try to make them unidirectional, so if you start deleting the leaf modules of your system, it should continue to work just with less capabilities.
If you kind of follow this recipe you will be able (when you need to) to extract modules from your system and deploy them independently, specially the leaf modules because no one will depend on them.
If you have any other kind of experience about this, please share it!