As a long-time perpetrator of monolithic systems (oh, the shame!), I recently had my eyes opened to the concept of microservices. I've now read lots of online articles, and enjoyed the piecemeal plan of the Strangler Pattern to break a monolith into microservices. I can see how especially with the advent of technologies like Kubernetes to manage all these disparate parts, it makes a lot of sense to have lots of small services that can be independently scaled and maintained by different development teams.
What's getting me stuck, though, is that everything I've found on the Web talks in abstract generalities, with very little actual code explaining how to do anything beyond CRUD in a microservice. Like, let's take the scenario of an application that has customers and products. There's one piece of the system that manages the sales and billing, and another piece that manages the tech support. What's common between them is Customer
and Product
. The sales side also has an Order
table, while tech support has a SupportTicket
.
So, what's the "correct" microservice architecture here, if we have to design this from scratch? Should we have separate microservices for each table? Or are "Sales" and "TechSupport" separate services? If the latter, who gets responsibility for maintaining Customers and Products? If the former, what happens in the event that Tech Support gets a ticket that is billable, and they won't start working on it until they get an Order
linked to their support ticket that shows it has been paid? What if business rules require that there needs to be a transaction boundary, so that the support ticket does not get created unless there is a matching, paid order?
I guess my broader question is that invariably, in real-world systems, things have dependencies on other things, and sometimes those dependencies are circular. How is it possible to have all these neat, lean microservices, that do nothing other than worry about their own bailiwick, when the reality is that it's very rare to have the luxury of not caring about anything else in the overall system?