41
CHAPTER 3 | Architecting container and microservice-based applications
•
How can client apps minimize the number of requests to the back end and reduce chatty
communication to multiple microservices?
Interacting with multiple microservices to build a single UI screen increases
the number of round trips
across the Internet. This approach increases latency and complexity on the UI side. Ideally, responses
should be efficiently aggregated in the server side. This approach reduces latency, since multiple
pieces of data come back in parallel and some UI can show data as soon as it’s ready.
•
How can you handle cross-cutting concerns such as authorization, data transformations, and
dynamic request dispatching?
Implementing security and cross-cutting concerns like security and authorization on every
microservice can require significant development effort. A possible approach is to have those services
within the Docker host or internal cluster to restrict direct access to them from the outside, and to
implement those cross-cutting concerns
in a centralized place, like an API Gateway.
•
How can client apps communicate with services that use non-Internet-friendly protocols?
Protocols used on the server side (like AMQP or binary protocols) are not supported in client apps.
Therefore, requests must be performed through protocols like HTTP/HTTPS and translated to the
other protocols afterwards. A
man-in-the-middle
approach can help in this situation.
•
How can you shape a facade especially made for mobile apps?
The API of multiple microservices might not be well designed for the needs of different client
applications.
For instance, the needs of a mobile app might be different than the needs of a web app.
For mobile apps, you might need to optimize even further so that data responses can be more
efficient. You might do this functionality by aggregating data from multiple microservices and
returning a single set of data, and sometimes eliminating any data in the response that isn’t
needed
by the mobile app. And, of course, you might compress that data. Again, a facade or API in between
the mobile app and the microservices can be convenient for this scenario.
Dostları ilə paylaş: