When choosing to build the application as a microservice, we will need to decide how the application’s clients will interact with those microservices. With a monolithic application, there is only one set of endpoints (usually replicated, load balancing). However, in the microservices architecture, each microservice has a detailed set of endpoints. Let’s see how this affects client-application communication, and how API Gateway can help solve the problem.
Let’s say you are developing a client for a mobile shopping application. You may need to implement a detailed product page to display information about all the specific products the service offers.
Although it is a mobile application, the product detail page displays a lot of information. For example, there is not only basic product information (like name, description, and price) but the page also displays:
Number of items in the cart
Low inventory alert
Various purchase recommendations, which can be products commonly purchased with the same product, other products also purchased by customers who have purchased this product, and other products purchased by customers who have purchased the product see this product
Alternative product recommendations
When using the microservices architecture, the data displayed on the product page resides in many different microservices. Some of the microservices whose data is displayed on the product page in the example can be classified as follows:
Service Cart – Number of items in the cart
Service Order – Order history
Service Directory – Basic product information such as name, image and price
Service Review – Customer Reviews
Service Inventory – Low Inventory Alert
Service shipping – Shipping options, times, and costs are segregated from the shipping provider’s API
Recommended Service(s) – Recommended Items
We need to decide how clients access these services.
If direct communication Client‑to‑Microservice
In theory, a client could make requests directly to each microservice. Each microservice will have a public endpoint. To get detailed product information, the client directly calls each of the services listed above via the public endpoint,
But, this approach has many challenges and limitations. The first is that the client’s needs and the APIs of each microservice may not match. The client in this example has to make 7 separate requests. In more complex applications, more calls may be required.
Another problem when clients call microservices directly is that some services may use protocols that are not web-friendly. Protocols such as HTTP and WebSocket are generally recommended.
Besides, the refactoring of microservices, such as merging 2 services into 1 or separating 1 service into 2 will be extremely difficult.
The challenges also come from the developer will have to develop separate Authentication and Authorization sections for each service, which is time consuming, difficult, or does not have a monitoring and logging system for each service (latency, timeout rate, log access). access of each service).
To better analyze these difficulties, and offer more effective solutions from API Gateway, readers should join Bizfly Cloud in Bizfly Expert Talk #36 with the topic: ”API Gateway in API Gateway” session. microservice architecture” takes place on March 9 here.
Join now to receive a trial voucher worth 500K when accessing: https://bit.ly/3MlV1G7
API Gateway is considered as a method that can solve all the difficulties mentioned above. API Gateway is a server (group of servers) that acts as a single entry/exit to access services. In addition to the task of routing the appropriate API for each client, API Gateway has functions such as authentication, monitoring, load balancing, rate limiting, health checks, logging, and security.
Providing the first pre-packaged API Gateway solution in Vietnam, developers will be a lot easier and more convenient in their development work, businesses save a lot of costs and hours of effort for their developers. deployment and operation. All will be revealed in an interesting and useful Talk from Bizfly Cloud.
Mr. Pham Van Khanh – Product Owner Bizfly API Gateway
He has extensive experience in implementing and operating the internal API Gateway system for Admicro and MXH Lotus advertising networks. At one point, this system served up to 90,000 requests/s.
Bizfly Cloud – operated by VCCorp – is currently a pioneer in providing complete cloud computing and technical infrastructure solutions and services for businesses across the country with major customers such as VTV, Vingroup , Dat Xanh Mien Bac, Ahamove, SSI, Sapo, VNDirect…