4

we are trying to create a microservice based software.

I like the thought, that all services should work on it own and hold all data that it needs. Also i like the concept that i hold datas up-to-date by messaging, so sending Created/Updated/Deleted events.

But now i stand in front of a problem, i will call it "data-initialization".

So ServiceA needs some data from ServiceB and had subscribed to all needed Events for that. Problem: ServiceA is an optional service so it can happen that ServiceA starts later (maybe a few weeks) then ServiceB.

So now i can do a data-initialization? A few thoughts to that:

  • REST-Call: But what if the data are really big? HTTP is sync-call so it blocks me a long time? Possible that there are too much data for an HTTP-Request?

  • other ways / ideas?

Thanks & Regard!

Flo
  • 1,179
  • 3
  • 15
  • 43
  • Is the problem that `ServiceA` will always need _all_ the events from `ServiceB` (even the ones that have occurred a very long time ago) - or is there a large amount of data to be transmitted regardless of the timing / startup behavior? Can you estimate how much data it will be? – Gerd May 15 '20 at 11:55
  • I looking for a general solution - so i look for a solution for large amount and small amount of data ;) In our case there will be booth cases. – Flo May 18 '20 at 06:39
  • Take a look at [this question](https://stackoverflow.com/questions/11725078/restful-api-handling-large-amounts-of-data), [this other question](https://softwareengineering.stackexchange.com/questions/273924/is-rest-useful-in-read-write-operations-that-involve-over-100-gig) and [this third question](https://stackoverflow.com/questions/51763355/returning-a-very-large-data-from-a-rest-api/51763433). This should give you an idea. – Gerd May 18 '20 at 09:16
  • @Gerd thanks but all of these questions a regarding a big http-request. The HTTP-call was just an idea i have to my problem. The question is - how to handle that is http the right way? – Flo May 18 '20 at 11:50
  • you could use kafka or rabbitmq for handling events(message queue). https://stackoverflow.com/questions/42151544/when-to-use-rabbitmq-over-kafka – abduljalil Mar 30 '23 at 06:33

1 Answers1

-1

For communication between microservices, both synchronous and asynchronous methods can be applied (see this article and this article).

Popular protocols include HTTP/REST (synchronous) and AMQP (asynchronous, message-oriented) - a general introduction describing the typical aspects can be found here.

This other article compares the different methods, suggesting that an HTTP/REST design tends to lead to a tighter coupling of the services and to have drawbacks due to the blocking nature of the protocol and a more difficult error handling (e.g. when a service is not available). In contrast, an asynchronous or event-driven design tends to result in a loose coupling of the services, better scalability and greater resiliency and simpler error handling.

As often, each approach has its specific advantages and drawbacks and the decision really depends on your application scenario.

Gerd
  • 2,568
  • 1
  • 7
  • 20