I have 3 different services which needs to access same database. Each of these service will serve different purpose and different queries. I can generalize them in following way
I have written a DAO to expose data. I am evaluating two system designs for scalability and maintenance.
Option 1: Write one more service to expose DAO functionality as Data Service.
Pros:
- Load on database will be controlled and easy to scale-in/out as needed
- Easy to maintain for future updates
- Access control for various actions
- clients doesn't have full access on underlying database
Cons:
- Single point of failure
- management of extra service
- Need to enforce backward compatibility rules
- In case of DataService downtime every service is affected (factors other than database downtime)
And
Option 2: Create a storage library out of DAO and use these library in above mentioned three services.
Pros:
- distributed, impact radius is very small
Cons:
- Every service get full access on database
- Needs to update all three services for new features
Thank you Rob and Maksym for your inputs.
I separated queries based on bounded context and created library and service for different context.
Inquiry and Order Service access data using data service. This helped me control noisy neighbor and resource allocation.
I replicated data from main database to reporting database and built a library for Reporting service to access reporting database.