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 location
  • score service manages users score

now, have build service: users feed service (ufs). has return users near given location, ordered score (descending).

synchronous solution

  1. given location, ufs fetch nearby users location service (rest)
  2. for each 1 of them, gets score score service (rest)
  3. 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

Popular posts from this blog

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -