Talking about BFF Architecture

BFF architecture learning

1. What is a BFF?

BFF is the backend that serves the frontend, the full name is Backend For Frontend . The position of BFF is between the client and the server, and it acts as a middleware.

2. What do BFFs do?

Let's look at the structure distribution diagram as follows:

insert image description here

Analyzing this picture, it can be easily seen that BFF gathers the interface data of the server, and then passes it to the front end after sorting and processing. In this way, the front end can directly call an interface to obtain data directly. And the back-end does not have to gather business codes together for the needs of the front-end. It facilitates front-end and back-end development. BFF downwards is various microservices on the server side, and upwards is to provide interface services for clients. The back end is the RPC interface provided by the front end of the BFF layer, and the BFF layer directly calls the RPC interface of the server to get the data, and processes the data as needed to complete the closed loop of the entire BFF (based on the Node+GraphQL technology stack)

3. What are the advantages and disadvantages of BFF?

Advantages of BFFs:

  1. Independence of the front and back ends achieves a decoupling effect.
  2. Multi-terminal application adaptation, when different terminals have different data requirements for the server interface, you can adjust the BFF layer and make different API calls to reduce Http requests.

Shortcomings of BFF:

  1. Repeated development: When developing a BFF application, the problem of repeated development of BFF will appear. Increased development costs.
  2. Increased maintenance costs: In the development of BFF applications, BFF needs to be maintained.
  3. Complex links: In the BFF process, not only the client but also the server must be considered, which leads to a cumbersome process.
  4. Waste of resources: Now there is an extra BFF layer, so the resource consumption will be more than before.

Suggestions to solve the shortcomings of BFF are load uniformity, monitoring and alarming, and other operation and maintenance operations

In summary, all the solutions above are ServerLess, Serverless = Faas (Function as a service) + Baas (Backend as a service)

Fass: It is a service provider that provides a platform for users to develop, run and manage these functions without building and maintaining the basic framework. It is an event-driven and message-triggered function service

Baas: Serving for the server, it contains many back-end components and is an excellent API-based third-party service. Contains database, message queue, log service, etc.

4. Application environment of BFF

  1. If the client needs a lot of data to display but the app does not need too much data, or a page needs a lot of interface requests, then BFF can be used to combine the data.
  2. For iterative display, rapid development is required for the new version of the page display, so that the data displayed on the page is different.
  3. If the display format of the server-side data is different, provide a good data format in order to make the front-end configuration better.

Guess you like

Origin blog.csdn.net/weixin_51220967/article/details/127496432