I know synchronous communication between services is an anti-pattern, so I'm searching for a good solution for my use-case.
I have this two services:
Location Servicethat manages users location
Score Servicethat manages users score
Now, I have to build another service:
Users Feed Service (UFS). It has to return users near to a given location, ordered by score (descending).
- Given a location, UFS fetch nearby users from the location service (REST)
- For each one of them, it gets her score from the Score Service (REST)
- Finally, it sorts the users in memory and return them
What is the alternative? I have been thinking about something like this:
Event queue solution
- UFS stores users locations and scores in a database, or memory cache or something
- It listens to changes in a queue to update its data when the score service and location service publish in it
This way, when client request the users feed, the users feed service don't have to perform any network request (it owns the necessary data)
Is this a good solution? How can I improve it? Will it scale to a lot of users?