官术网_书友最值得收藏!

Communication between microservices

In the preceding section, we separated our Order module into Order Services and discussed how we can break down the foreign key relationship between ORDER and PRODUCT tables.

In a monolithic application, we have a single repository that queries the database to fetch the records from both ORDER and PRODUCT tables. However, in our upcoming microservice application, we will segregate repositories between Order Service and Product Service. With each service having its respective database, each one would access its own database only. Order Service would only be able to access order Database, whereas Product Service would be able to access product Database only. Order Service should not be allowed to access product Database and vice versa. Refer to the following image:

We will discuss communication between microservices in Chapter 3, Integration Techniques, in detail.

In the preceding figure, we see that our UI is interacting with Order Service and Product service via API gateway. Both the services are physically separated from each other and there is no direct interaction between these services. Communication performed in this manner is also referred to as communication that is based on the API Gateway Pattern.

The API gateway is nothing but a middle tier via which the UI can interact with the microservices. It also provides a simpler interface and makes the process of consuming these services simpler. It provides a different level of granularity to different clients as required (that is browser and desktop).

We can say that it provides coarse-grained APIs to mobile clients and fine-grained APIs to desktop clients, and it can use a high-performance network underneath its hood to provide some serious throughput.

The definition of granularity from wiki:

Granularity is the extent to which a system is broken down into small parts, either the system itself or its description or observation. It is the extent to which a larger entity is subdivided. For example, a yard broken into inches has finer granularity than a yard broken into feet.
Coarse-grained systems consist of fewer, larger components than fine-grained systems; a coarse-grained description of a system regards large subcomponents while a fine-grained description regards smaller components of which the larger ones are composed.
主站蜘蛛池模板: 綦江县| 安仁县| 白河县| 凯里市| 鄢陵县| 雷波县| 河间市| 凤凰县| 资兴市| 重庆市| 木兰县| 东港市| 福贡县| 文安县| 江孜县| 珠海市| 芜湖县| 东丰县| 辽宁省| 乌鲁木齐县| 红桥区| 日土县| 高唐县| 朝阳区| 项城市| 奉贤区| 盘锦市| 汝南县| 沧州市| 惠州市| 澄江县| 安新县| 南阳市| 广河县| 松江区| 化州市| 民丰县| 朝阳市| 东山县| 蒙山县| 青神县|