In an event-driven microservice architecture, imagine we have three services:
- Customer service
- Order service
- Item service
Each service raises an event with data when something happens and stores only its related transactions.
For example, we want to know the customers that placed an order in the 30 min after they registered, and the items it contains.
In a monolith with one database it would be trivial, but I'm thinking what could be the best option in this scenario.
Could it be feasible to have an "ancillary" service that listens for all the events and stores that event data in a single relational database so then it can be queried without bothering the services itself? If not, what could be a solution?
-
1Some analytics tools will automatically do this out-the-box with minimal configuration (For example Splunk already has many different listening/forwarding capabilities which can be configured to consume from any number of sources into its own analytics database). I believe DataDog has similar capabilities, along with many other similar tools -- it would be worth investigating these in case any of them meet your needsBen Cottrell– Ben Cottrell2021年11月11日 11:36:01 +00:00Commented Nov 11, 2021 at 11:36
-
1In a monolith with one database it would be trivial So make one, and load it with data from your microservices on a regular basis. This is called a data warehouseJohn Wu– John Wu2021年11月11日 17:08:34 +00:00Commented Nov 11, 2021 at 17:08
-
Thanks both, I explored the options and Google Cloud's BigQuery seems to be a good fit for my use case.lewislbr– lewislbr2021年11月15日 08:47:36 +00:00Commented Nov 15, 2021 at 8:47
1 Answer 1
Could it be feasible to have an "ancillary" service that listens for all the events and stores that event data in a single relational database so then it can be queried without bothering the services itself
You answered your own question. :-) Correct. That's exactly how I do it. Create an "Analytics" service that collates all the events/data it needs from the whole system and then produce specific views of that data from your analytics service.