12.07.2019 Views

NET-Microservices-Architecture-for-Containerized-NET-Applications-(Microsoft-eBook)

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

The API Gateway pattern versus the Direct client-to-microservice<br />

communication<br />

In a microservices architecture, each microservice exposes a set of (typically) fine‐grained endpoints.<br />

This fact can impact the client‐to‐microservice communication, as explained in this section.<br />

Direct client-to-microservice communication<br />

A possible approach is to use a direct client-to-microservice communication architecture. In this<br />

approach, a client app can make requests directly to some of the microservices, as shown in Figure 4-<br />

12.<br />

Figure 4-12. Using a direct client-to-microservice communication architecture<br />

In this approach. each microservice has a public endpoint, sometimes with a different TCP port <strong>for</strong> each<br />

microservice. An example of a URL <strong>for</strong> a particular service could be the following URL in Azure:<br />

http://eshoponcontainers.westus.cloudapp.azure.com:88/<br />

In a production environment based on a cluster, that URL would map to the load balancer used in the<br />

cluster, which in turn distributes the requests across the microservices. In production environments,<br />

you could have an Application Delivery Controller (ADC) like Azure Application Gateway between your<br />

microservices and the Internet. This acts as a transparent tier that not only per<strong>for</strong>ms load balancing,<br />

but secures your services by offering SSL termination. This improves the load of your hosts by<br />

offloading CPU-intensive SSL termination and other routing duties to the Azure Application Gateway.<br />

In any case, a load balancer and ADC are transparent from a logical application architecture point of<br />

view.<br />

A direct client-to-microservice communication architecture could be good enough <strong>for</strong> a small<br />

microservice-based application, especially if the client app is a server-side web application like an<br />

ASP.<strong>NET</strong> MVC app. However, when you build large and complex microservice-based applications (<strong>for</strong><br />

40 Architecting Container- and Microservice-Based <strong>Applications</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!