常用的几个开源 API网关管理系统

Manage your Web API with an API Gateway

Written by David Martin and translated by Romain.

The primary purpose of a web API is to expose data to be consumed or changed. Fairly quickly, the question of securing access to such data presents itself. And other aspects become critical too, such as performance management API or the respect of access quotas.

When it comes to a single API, the most direct approach to treat these secondary but important needs is to directly add these responsibilities in the API itself. Many solutions exist for this. Security solutions can be more or less sophisticated: simple htaccess protecting access to resources, using a library such as Spring Security or Apache Shiro if developments are made in Java, Passport with NodeJS bookstore, etc. Once the caller’s identity is known, quota management is only a matter of reads & writes to a counter. Cache management can be done through dedicated libraries or by the same libraries used to build the API (Jersey, Restlet, etc.)

Since creating a Web API is now rather simple, APIs tend to proliferate. When the number of APIs becomes quite important, these requirements obviously can be considered cross-cutting needs. And therefore it is not unreasonable to suggest that they can be treated outside the API.
How to implement these cross-cutting needs? A reverse proxy is a possible approach. This component is commonly called an API Gateway.

A typical API Gateway includes:

  • Security (authentication, and potentially, authorization)
  • Managing access quotas and throttling
  • Caching (proxy statements and cache)
  • API Composition and Processing
  • Routing (possibly processing) to an “internal” API
  • API health monitoring (performance monitoring, error …)
  • Versioning (with the possible negotiation of automatic version)

 

API-Gateway

Advantages:

  • Implemented in one single place
  • Simplifies the API source code itself, since these concerns are externalized
  • Provides a central and unique view of the API and therefore be more likely to allow a consistent policy

Drawbacks:

  • Possible single point of failure or bottleneck
  • Risk of complexity, since all the API rules are in one place
  • Risk of lock-in, and migrating away may not be simple

Is it a great idea that nobody has thought of yet? No, far from it, since many publishers now have solutions of this kind, with variable amounts of features and different maturity levels. Commercial products are now numerous and started to get acquired by large publishers cycles (example: Intel acquired Mashery in 2013, Computer Associates acquired Layer 7 in 2013) or to enter partnerships (SAP and Apigee 2014). Not all are equal, some stand out and have already gained notoriety (Layer 7 for instance, with his API guru workforce).

What about open-source?
There are some open source initiatives but strangely, this market is yet to be taken (anyone up for it?):

All these solutions do not have the same traction in the world of open source and are not equal, far from it, in terms of features. To date, WSO2 API Manager is the richest in features and is well-polished. It is a good platform candidate to implement an API Gateway at a reasonable cost (cost of learning the technology and deploying it). Even though this solution is advanced, it does not necessarily cover the full spectrum of features of its commercial competitors.

There is always the possibility of custom-assembling a solution when the needs do not seem to justify the adoption of a turnkey product. Several open source reverse proxy solutions can be configured to provide the basic functionality of an API Gateway. But beware the long-term costs of this approach.

In conclusion, carefully analyze your needs to identify the appropriate strategy: supporting these aspects in the API itself may look like a good and cheap option, but it will lose its appeal if your API portfolio grows. Soon enough, the adoption of a specialized solution will prove to be a good investment. Whether it is open source or not, free or not, custom or off the shelf, on-premise or SaaS, and so on, will depend on many other parameters that need to be examined.



来源: http://www.ipponusa.com/blog/api-gateway/

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
### 回答1: 基于Spring Cloud的农业溯源系统是一套用于追踪和记录农产品供应链的系统。该系统使用微服务架构,基于Spring Cloud框架开发,实现了不同环节之间的数据传递和交互。 农业溯源系统的源码可以分为以下几个模块: 1. 注册中心模块:使用Spring Cloud Netflix Eureka作为注册中心,负责管理所有微服务的注册和发现。每个微服务都会注册到注册中心,便于其他服务发现和调用。 2. 鉴权认证模块:使用Spring Security实现用户身份认证和权限控制。用户可以通过注册和登录获取访问系统的权限,并且根据不同角色进行权限的控制。比如,农民只能查看自己的产品信息,而管理员可以对产品进行审核和管理。 3. 产品信息管理模块:该模块负责记录和管理产品的基本信息。每个产品都有一个唯一的标识符,可以通过该标识符追溯到该产品的生产环节和流通路径。产品的信息包括生产地点、生产时间、运输方式等,可以通过接口对这些信息进行增删改查操作。 4. 供应链管理模块:该模块负责记录产品的供应链信息。每个产品都有一个由多个节点组成的供应链,包括农民、经销商、运输商等。每个节点都可以通过接口将自己的信息添加到供应链中,并且可以查询该产品的供应链信息。 5. 数据分析模块:使用Spring Cloud Stream实现数据的实时分析和处理。系统通过消息队列将产生的数据发送到该模块,进行数据清洗、处理和分析,并可以生成各种报表和统计信息,帮助农民了解产品的质量和市场需求。 农业溯源系统基于Spring Cloud的源码是一个完整的微服务架构项目,通过各个模块的协作,实现了农产品供应链的追溯和管理。通过对源码的分析和定制,可以根据具体的需求进行二次开发和扩展,进一步提升系统的功能和性能。 ### 回答2: 基于Spring Cloud的农业溯源系统源码是指使用Spring Cloud技术栈开发的农业溯源系统的源代码。Spring Cloud是一套基于Spring Boot的开源框架,用于构建分布式系统和微服务架构。农业溯源系统的主要功能是追踪和记录农产品的生产流程和品质信息,实现农产品从种植或养殖到消费环节的全程可追溯。 源码中包含了系统的各个模块的代码,主要包括以下几个方面: 1. 注册中心:在Spring Cloud中通常使用Eureka作为注册中心,它用于管理所有微服务的注册和发现。源码中会包含Eureka Server的配置和相关代码。 2. 配置中心:通常使用Spring Cloud Config作为配置中心,用于集中管理各个微服务的配置信息。源码中会包含Config Server的配置和相关代码。 3. 网关服务:使用Spring Cloud Gateway或Zuul作为网关服务,负责路由、负载均衡、权限控制等功能。源码中会包含网关服务的配置和相关代码。 4. 微服务:农业溯源系统通常包含多个微服务,每个微服务负责不同的功能模块。源码中会包含这些微服务的业务逻辑代码,如农产品管理、溯源信息记录、供应链管理等。 5. 数据库访问:农业溯源系统通常使用关系型数据库存储数据,如MySQL或PostgreSQL。源码中会包含与数据库的交互代码,包括实体类定义、数据库查询和更新等。 总结来说,基于Spring Cloud的农业溯源系统源码包括了各个模块的配置和业务代码,用于实现系统的注册与发现、配置管理、路由转发以及各个功能模块的实现。 ### 回答3: 基于SpringCloud的农业溯源系统源码主要包含以下几个模块:注册中心、配置中心、网关、业务模块和数据存储模块。 注册中心模块采用Eureka作为服务注册与发现组件,所有的微服务通过向注册中心注册自己的信息,来实现服务的自动发现和调用。 配置中心模块使用Spring Cloud Config,将配置文件集中管理,实现对不同环境的配置管理和动态刷新配置。 网关模块使用Spring Cloud Gateway,提供统一的访问接口和安全认证,对外屏蔽了后台多个微服务的具体实现,实现了负载均衡和流量控制的功能。 业务模块是整个系统的核心,包含了农产品追溯的具体业务逻辑。通过调用其他微服务提供的接口,实现农产品的录入、查询、溯源等功能。 数据存储模块使用MySQL数据库来存储农产品的相关信息,通过使用Spring Data JPA来简化数据库访问和操作。 在源码中,我们可以看到各个模块之间通过RESTful API进行通信,使用Feign来进行服务之间的调用。同时,源码中还会包含一些基于SpringCloud的组件,如Hystrix实现服务的容错和熔断,Ribbon实现负载均衡等。 总的来说,基于SpringCloud的农业溯源系统源码通过使用微服务架构,实现了系统的拆分和解耦,并提供了一些常用的组件和工具来简化开发和部署。通过源码学习,可以深入了解SpringCloud的使用和微服务架构的实现。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值