as I understand it micro-services are autonomous and have complete control over their own data and therefor each micro-service has a dedicated database.
I was wondering what would be the approach to implement reporting in a micro-services architecture, if reports depend on data that exists in multiple databases where each database is governed by its own micro-service.
3
I’m not exactly sure why a micro-service should have ‘complete control over their own data’. What I understood is, that a micro-service should be stateless.
That means it should not depend its ‘action’ on some state (possible from a database), but only from the ‘input’ data (eg: message) – therefore it’s action should be repeatable when the ‘same’ input triggers the action at any given time.
A service which depends on ‘changing-over-time’ reporing data may not have those properties, but it totally depends on your use-cases. If you ‘just’ trigger the generation of a report, the output may (and must) change over time.
Perhaps a micro-service architecture may not be the best fit for a reporting applicaction…
Yes, micro-services should operate on their own datasets, but this doesn’t have to mean individual databases, it can be schemas or even just a few tables in an existing DB. Just as long as you know who has ownership over what data, you should be good.
But reporting… typically this does not occur on the live databases, you would extract data from the main DBs to a reporting DB where you run all manner of slow and intensive queries. How you get the data extracted is up to you – either a dedicated SQL task, or you have a method on your services that exports data for import into the report DB.