I'm trying to design an application that uses the microservices architecture. The service would have an api gateway, a user service and then a seperate service for each analytic source.

For example, lets say I had twitter analytics data and instagram analytics data. There would be a seperate microservice for twitter analytics data and instagram analytics data. These microservices would handle oauth for that service, storing data and pulling data. My question is this: how would I request data from one service, lets say the user service, and then based on data from the user service, make a request to the instagram service and twitter service to request analytics info for that user.

However what would happen if I had n amount of services that I needed to request to? Like let's say a user needs analytics data from facebook, instagram, twitter and tiktok. How would I handle making a seperate request to each and then combine into a single response for the client?

I was thinking of using an api gateway as I've read that you can support request fanning-out to multiple microservices. I'm exactly sure how to do that however I found this article from aws outlining the different strategies.

I've also read over this question that says "You should implement endpoints in the services to facilitate these two requests. If you're making n requests, you've done it wrong". So now I'm not even sure if I'm on the right track.

Am I approaching this the correct way?

  • It's difficult to answer this without knowing why you are doing it this way. Are the different services worked on by different teams, are those 3rd party, or scale differently? Why is there are need to distribute these steps? May 30 at 15:48
  • I feel there is a need to seperate the services as each of these services are fetching a users analytics from a third party api (twitter, facebook, etc) and then storing the analytics. If all the services were combined into 1 monolith, wouldn't it be hard to add more third party providers and manage everything in general?
    – user
    May 30 at 16:29
  • Again, depends. If the app is under your control, you can make it as easy to extend as you want. Even as a monolith. From polymorphism to plugins everything is possible. Making it a distributed system makes it complicated, hence less maintainable by default. So unless it solves another problem for you, I would not go there. May 30 at 19:52


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.