I’m developing a Microservices Web Chat Application using Spring boot and Websockets.
Right now my concern is the following: it seems like each one of my microservices need to make a lot of calls to another services for just a requests what makes everything tighly coupled.
For example, when user A connects to the app, it needs to receive all its conversations (let’s say just one on one type for the moment), so, it sends a request to Conversation Service with the user Id, and this service fetch all user conversations from DB, then, the problem starts here:
- Each conversation object has a participants ids list attribute (user A and user B), so, using the id of the another user (the receiver, user B), conversation Service calls, for each conversation:
- User service for username
- Profile Image service for user image
- Presence service for online/offline status
- Unread messages service for conversation unread messages amount
At the end, this is a lot of work and calls for just one request and obviously I feel there is something wrong here but I can’t figure out the best way to follow in this situation.
I would appreciate a lot your feedback and criticism, and thanks in advance!!
I’ve been tried to “store” common users data in the same service, for example User services stores profile image now (is there not need of profile image service maybe?), and instead of just participants ids in conversation objects, also their usernames, but at the end this still require a lot of calls from conversation service if user needs to fetch a lot of its conversations at once