Current location - Training Enrollment Network - Education and training - Computer training shares the basic knowledge of API gateway setting.
Computer training shares the basic knowledge of API gateway setting.
If you know the network structure, you should be familiar with the gateway. Today, let's take a look at some basic knowledge of API gateway, hoping to be helpful to your future server development. Let's start today's main content.

First, the background of API gateway

In the micro-service architecture, a large application will be divided into several small individual services. These small services have their own processing, their own database (you can also use * * *), and perhaps the language is different. They can be deployed on one or more servers, which is actually to decouple complex applications. So why do microservices need API gateways?

Let's look at the problems arising from microservices:

Clients need to know multiple service addresses.

How to deal with general functions? Such as authentication, flow control, logging, etc.

In the past, a function may be completed with one request, but now it may require multiple services to be carried out together. How can we reduce the time required by customers?

Because of the above problems, it is necessary to define a proxy in front of all services, that is, API gateway. All client requests must reach the real service address through the API gateway, which can effectively avoid the exposure of the real address. At the same time, API gateway can also integrate authentication, flow control, logging, API aggregation, black and white list and so on.

Second, the introduction of the hole

Kong is an API gateway framework developed by Mashape and open source on 20 15. It is based on nginx and OpenResty, and its main features are high performance and strong expansibility. Because it is developed based on nginx, many online tuning materials about nginx can be used on Kong, including load balancing or acting as a web server.

The expansion of the hole is carried out through the plug-in mechanism, and a sample method of plug-in customization is also provided. Plug-ins define the whole life cycle of a request from input to feedback to the client, so computer training thinks it can meet most customization needs. The hole itself integrates many plug-ins, including CORS cross-domain, log, current limiting, forwarding, health check, fuse and so on. Since github, the API aggregation function has also entered the development stage.