0

I'm developing a webapp based in the microservices design. In my project each microservice will be a module in the same app as recommended by the documentation. But If I think how these microservices talk to each other I think (if I were out of GAE) in API REST but I read about endpoints and I don't know to communicate modules who is the best way.

The doc about this (Communication between modules) is a bit poor, and don't say how is the way to communicate, only say how share information from datastore.

Someone that have experience about modules and his communication, can say me how is the best way to made a good communication among them?

Sometimes I think that GAE is not the best platform to deploy an app with many microservices that communicating with each other.

Thanks you so much.

Juan Antonio
  • 2,451
  • 3
  • 24
  • 34

1 Answers1

0

Using REST (or endpoints for that matter) may be overkill for communicating between modules since you're not actually communicating from/to outside the application. You'd be wasting CPU time (de) serializing and/or encoding/decoding data unnecessarily, for example.

If in a module you need data stored by another module you can simply get it from the datastore. You can model inter-model communication as a plain API or (my preference) directly as object methods. It's also simpler to address datastore eventual consistency issues by passing around keys directly - safer since it's all inside your app.

If you need to pass events between modules you can use plain url requests, or task queue requests, or deferred tasks, etc.

Dan Cornilescu
  • 39,470
  • 12
  • 57
  • 97
  • Thanks for the comments. If I do url request as you say, is not the same that call to REST api ? If i understand, with urllib2 for example (as the documentation says) I can call to resources from other module, but this is an API REST (for example). or not?. So, I will have to build a response in json, for example, not? Well, you comment about inter-model communication directly as object methods is very interesting. You can explain a bit more about this? You could you do calls between modules calling methods directly? Thanks again. – Juan Antonio Dec 25 '15 at 10:46
  • Say one module creates a db entity and you want to pass it to another module for processing. Using REST one module would read the entity, encode it and pass it to the other module which would decode it, etc. But the 1st module could just pass the entity key in the request and the receiving module would just call `key. get() ` to get the data. You could also share a class definition between modules, with methods that each module can call directly as needed (see, for example, http://stackoverflow.com/questions/34291075/sharing-entities-between-app-engine-modules/34291789#34291789) – Dan Cornilescu Dec 25 '15 at 19:27