没有合适的资源?快使用搜索试试~ 我知道了~
首页Microservice API Gateway Patterns
Microservice API Gateway Patterns
需积分: 10 98 浏览量
更新于2023-05-28
评论
收藏 945KB PDF 举报
API Gateway Patterns for microservice. describe the API gateway pattern. I discuss its bene ts and drawbacks. I also describe various design issues that you must address when developing an API gateway
资源详情
资源评论
资源推荐

10/9/2018 The API Gateway Pattern | Manning
https://freecontent.manning.com/the-api-gateway-pattern/ 1/14
From Microservices Patterns by Chris Richardson
In this article, I describe the API gateway pattern. I
discuss its benets and drawbacks. I also describe
various design issues that you must address when
developing an API gateway.
Save 37% on
Microservice Patterns
. Just enter code fccrichardson into the discount
code box at checkout at manning.com.
As you may know, there are numerous drawbacks with services accessing services
directly. It’s often impractical for a client to perform API composition over the
Internet. The lack of encapsulation makes it difcult for developers to change
service decomposition and APIs. Services sometimes use communication protocols
that aren’t suitable outside of the rewall. Consequently, a much better approach is
to use what’s known as an API gateway.
Pattern: API gateway
The API Gateway Pattern

10/9/2018 The API Gateway Pattern | Manning
https://freecontent.manning.com/the-api-gateway-pattern/ 2/14
Implement a service which is the entry point into the microservices-based
application from external API clients. See:
http://microservices.io/patterns/apigateway.html.
An API gateway is a service which is the entry point into the application from the
outside world. It’s responsible for request routing, API composition, and other
functions, such as authentication. Let’s take a look at the API gateway pattern.
Overview of the API gateway pattern
The drawbacks of clients making multiple requests in order to display information
to the user are well known (I describe them in my book!). A much better approach is
for a client to make a single request to what’s known as an API gateway. An API
gateway is a service which is the single entry-point for API requests into an
application from outside the rewall. It’s similar to the Facade pattern from object-
oriented design. Like a facade, an API gateway encapsulates the application’s
internal architecture and provides an API to its clients. It might also have other
responsibilities, such authentication, monitoring, and rate limiting. Figure 1 shows
the relationship between the clients, the API gateway, and the services.

10/9/2018 The API Gateway Pattern | Manning
https://freecontent.manning.com/the-api-gateway-pattern/ 3/14
Figure 1. The API gateway is the single entry-point into the application for API calls
from outside the rewall
The API gateway is responsible for request routing, API composition, and protocol
translation. All API requests from external clients rst go to the API gateway. The
API gateway routes some requests to the appropriate service. The gateway handles
other requests using the API Composition pattern and invoking multiple services
and aggregating the results. It might also translate between client-friendly
protocols such as HTTP and WebSockets and client-unfriendly protocols which are
used by the services.
Request routing
One of the key functions of an API gateway is request routing. An API gateway
implements some API operations by routing requests to the corresponding service.
When it receives a request, the API gateway consults a routing map that species
which service to route the request to. A routing map might, for example, map an
HTTP method and path to the HTTP URL of a service. This function is identical to
the reverse proxying features provided by web servers such as NGINX.
API Composition
An API gateway typically does more than reverse proxying. It might also implement
some API operations using API composition. In my book, I use an example
application called FTGO to teach how to move from monolithic architecture to
microservices. The FTGO API gateway, for example, implements the Get Order
Details API operation using API composition. As gure 2 shows, the mobile
application makes one request to the API gateway, which fetches the order details
from multiple services.
剩余13页未读,继续阅读


















安全验证
文档复制为VIP权益,开通VIP直接复制

评论0