I have couple of services in my microservice architecture.
Two of the service(Service A, Service B) got different api's and provide different domain logic. However they do share some logic that should be returned - user-state from Redis.
- When user state is changed Iam publishing from a 3rd service to all the my micro-services
solutions:
I could create another service which would be responsible for "user-state" and will hold all user data on Redis. Disadvantages: My clients going to have additional call on every api requests(to get the user-state).
Duplicate the user-state datasource for each microservices(holding more than one redis instance) and return it independently for each request. Disadvantages: I am going to duplicate my data and duplicate Redis instances(each microservice will access it's own)
have one redis datasource while all services going to use it. Disadvantages: Duplicating redis-logic(in order to retrieve the data) among the services and break microservices principle by using one shared datasource
What would you suggest doing?