API 网关如何工作?
Posted 禅与计算机程序设计艺术
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了API 网关如何工作?相关的知识,希望对你有一定的参考价值。
API 网关如何工作?
在本文中阅读和探索 API 网关、其优势及其工作原理!
鲁奇塔·瓦玛
API 网关是微服务架构的重要组成部分。API 网关是一种软件模式,它放置在应用程序编程接口 (API) 或一组微服务之前,以促进传入请求和传出数据和服务的交付。在此 API Gateway 文档中阅读有关 API Gateway、其优势及其工作原理的信息!
什么是 API 网关?
真正的 API Gateway 是什么意思?API 网关是存在于客户端和后端服务集合之间的 API 管理工具。API 网关充当反向代理来接受所有应用程序编程接口 (API) 调用,聚合满足请求所需的各种服务,然后返回适当的结果。
API网关的主要功能!
一个 API 网关,它接受应用程序用户的请求,将其路由到一个或多个后端服务,收集适当的数据并将其以单个组合包的形式交付给用户。它还为应用程序提供分析、威胁防护和其他安全性。
API 网关的主要作用是充当组织的应用程序、数据和服务以及内部和外部客户之间交互的单一入口点和标准化流程。
API 网关如何工作?
API 允许不同的应用程序相互通信并在架构内外交换数据。API 网关提供了一个中心焦点和标准接口来执行这些交换活动。它接收来自内部和外部来源的请求,称为“API 调用”,并打包这些多个请求,将它们路由到适当的 API 或 API,然后将响应传递给发出请求的特定用户或设备。
API 网关处理的其他功能!
API 网关经常处理的与微服务相关的其他重要功能包括:
协议翻译
用于识别服务实例位置的服务发现。
在每个服务中构建基本业务逻辑
身份验证和安全策略实施
稳定和负载均衡
缓存管理
监控、记录和分析
使用 API 网关的好处!
在阅读了 API Gateway 的含义之后,现在让我们来了解一下它的好处。API 网关对于微服务架构至关重要。使用 API 网关的一些好处包括:
API 网关在将所有流量路由到目标服务之前对其进行身份验证。它可以自己执行自我身份验证,也可以使用外部身份验证提供程序来完成任务。
API 网关可以提供一个服务注册表,记录所有可用的服务实例。
API 网关可以保护服务免受峰值或 DDoS 攻击。
API 网关能够收集有关通过它的所有入站流量的指标、日志和跟踪。
使用 API 网关的注意事项!
如果不讨论在将其添加到应用程序之前必须牢记的关键注意事项,此 API Gateway 文档将是不完整的。API 网关可以通过身份验证、流量管理、负载平衡、威胁防护和可观察性等功能增强基于微服务的应用程序。如果没有正确配置,它可以关闭整个应用程序。因此,在将其添加到您的应用程序架构之前,您的团队必须对应用程序功能及其需要解决的真正问题进行适当的分析!
但是,它并不像看起来那么简单,管理微服务本身就是一项艰巨且具有挑战性的任务。监控、维护和部署微服务无疑是一个艰难的过程!
How do API Gateways Work?
Read & explore API Gateways, its benefits and how it works, here in this article!
By Ruchita Varma
API Gateway is a vital component of the Microservices architecture. An API gateway is a software pattern that is placed in front of an application programming interface (API) or group of microservices, to facilitate incoming requests and outgoing delivery of data and services. Read about API Gateway, its benefits and how it works, here in this API Gateway documentation!
What is an API Gateway?
What’s the real API Gateway meaning? An API gateway is an API management tool that exists between a client and a collection of backend services. An API gateway acts as a reverse proxy to accept all application programming interface (API) calls, aggregate the various services required to fulfil the requests and then return the appropriate result.
The Main Function of an API Gateway!
An API gateway that takes an application user’s request, routes it to one or more backend services, gathers the appropriate data and delivers it to the user in a single, combined package. It also provides analytics, protection against threats and other security for the application.
The primary role of an API Gateway is to act as a single entry point and standardized process for interactions between an organization’s apps, data and services and internal and external customers.
How does an API Gateway work?
APIs allow separate applications to communicate with each other and exchange data within and outside the architecture. The API gateway provides a central focal point and standard interface to perform these exchange activities. It receives requests from internal and external sources, called “API calls,” and packages these multiple requests, routes them to the appropriate API or APIs, and then delivers the responses to the particular user or device that made the request.
Other Functions that API Gateways handle!
Other important functions related to Microservices that API gateways often handle include,
Protocol translation
Service discovery for identifying the location of service instances.
Building basic business logic within each service
Authentication and security policy enforcements
Stabilization and load balancing
Cache management
Monitoring, logging and analytics
Benefits of using API Gateways!
After reading about API Gateway meaning, now let’s read about its benefits. API Gateways are essential to a microservice architecture. Some of the benefits of using API Gateways include,
An API Gateway authenticates all traffic before routing it to the target service. It can perform self-authentication itself or use external authentication providers to accomplish the task.
An API Gateway can provide a service registry that keeps a record of all available service instances.
An API Gateway can protect services from spikes or DDoS attacks.
An API gateway has the ability to collect metrics, logs, and traces about all inbound traffic passing through it.
Caveats of using API Gateways!
This API Gateway documentation would be incomplete without discussing the key caveats that you must bear in mind before adding it to your applications. An API Gateway can enhance your microservice-based application with capabilities such as authentication, traffic management, load balancing, threat protection, and observability. If not properly configured, it can shut down the entire application. So, before adding it to your application architecture, your team must do a proper analysis of the app features and the real problem that it needs to address!
But, it’s not as simple as it looks so, managing microservices is in itself a demanding and challenging task. Monitoring, maintaining and deploying Microservices is undoubtedly a tough row to hoe!
以上是关于API 网关如何工作?的主要内容,如果未能解决你的问题,请参考以下文章