Skip to main content

Microservices Patterns - With examples in Java

Page 296

266

CHAPTER 8 External API patterns

Browser client team

Mobile client team

Browser JavaScript application

Mobile client

Owns Mobile API gateway

3rd-party application

Owns Browser API gateway

API layer

Public API team

API layer

Owns Public API gateway API layer

Mobile API

Browser API

Public API

Common layer

Common layer

Common layer

Figure 8.7 The Backends for frontends pattern defines a separate API gateway for each client. Each client team owns their API gateway. An API gateway team owns the common layer.

The public API team owns and operates their API gateway, the mobile team owns and operates theirs, and so on. In theory, different API gateways could be developed using different technology stacks. But that risks duplicating code for common functionality, such as the code that implements edge functions. Ideally, all API gateways use the same technology stack. The common functionality is a shared library implemented by the API gateway team. Besides clearly defining responsibilities, the BFF pattern has other benefits. The API modules are isolated from one another, which improves reliability. One misbehaving API can’t easily impact other APIs. It also improves observability, because different API modules are different processes. Another benefit of the BFF pattern is that each API is independently scalable. The BFF pattern also reduces startup time because each API gateway is a smaller, simpler application.


Turn static files into dynamic content formats.

Create a flipbook