architecture - Alternative to synchronous REST communication betweeen microservices -
i know synchronous communication between services anti-pattern, i'm searching solution use-case.
i have 2 services:
location service
manages users locationscore service
manages users score
now, have build service: users feed service
(ufs). has return users near given location, ordered score (descending).
synchronous solution
- given location, ufs fetch nearby users location service (rest)
- for each 1 of them, gets score score service (rest)
- finally, sorts users in memory , return them
what alternative? have been thinking this:
event queue solution
- ufs stores users locations , scores in database, or memory cache or something
- it listens changes in queue update data when score service , location service publish in it
this way, when client request users feed, users feed service don't have perform network request (it owns necessary data)
is solution? how can improve it? scale in large amount of users?
maybe have additional requirements you're not listing seems me in case event based solution replicate lots of data other services way-way on engineering.
if ufs gets location when there changes in location service- makes sense tie invocation event coming location service on changes in locations
in regard scores service, i'd leave synchronous make interface accept list of customers rather making n "get customer score" calls it.
Comments
Post a Comment