Microservice architecture - Data initialization

Viewed 419

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!

1 Answers

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.

Related