Gateway implemented based on Fasthttp, performance comparable to Nginx

Continued from the article " A Golang Gateway "

In this article, a Gateway implemented in the go language is mentioned that is ready to be open source. In contrast, the gateway component in springcloud is developed and implemented in the go language.

The gateway in springcloud can realize gateway configuration with the configuration center, and can be combined with hytrix and alibaba’s Sentinel to realize the function of fuse and current limit. After springcloud is upgraded to 3.0.1, hytrix in netfix is ​​abandoned, and the new fuse resistance4j is used. , these types of current limiters do not provide a relatively complete management interface for management, sentinelboard provides management tools, but to achieve complete dynamic and configuration management, you must add your own code, the sentinel project open sourced by alibaba, this piece The code is currently not public. And it is very troublesome to use.

Therefore, in the project of implementing the gateway of golang, first of all, it is like improving the function of this piece, not only to provide the function of the gateway, but also to have a more friendly configuration and management tool. What I want to share with you today is this golang gateway management tool. This tool is a sub-project of boot4o-gateway. It completely cooperates with boot4go-gateway-server to perform the configuration management function of boot4go-gateway.

The project uses fasthttp to provide web http services, which is much faster than the original net/http. The interface is implemented using components of CubeUI.

statistics panel

Multi-domain name support, refer to the domain name function of nginx, which is not available in springcloud-gateway

Blacklist at the domain name level, the blacklist has multi-level support

Proxy that supports SSL ports, certificates are dynamically configured

Under the domain name, it supports matching and mapping of multi-level paths

Path mapping, powerful path mapping and path template conversion function, not only the function of API gateway like spring-gateway, but also a reverse proxy service similar to nginx function, here you can also configure fuse, current limit, private Forwarding, load balancing.

For endpoint support, currently it is a target group composed of supported single targets. In the future, it is planned to support ZK and NACOS service governance.

Dynamic Test Mapping Rules

Dynamic test path conversion, powerful parsing and template functions, and high key performance

SSL certificate management, support https

instance management

Gateway-Manager fully uses Etcd as the configuration center to save data configuration, uses EtcD as the bottom layer of Gateway’s service management, Gateway’s service components, start automatic registration to etcd management center, Gateway-Manager’s configuration information, and Gateway’s health Status is governed and mutually notified entirely through Etcd.

In this project, etcd is used a lot, and the query data in etcd is all queried through the command line of etcd, which is very inconvenient. I am planning to create a UIManager for etcd.

In this project, some of the functions involved are divided into sub-projects,

For example, the integration of etcd uses boot4go-etcd. Encapsulated watch, bulkops, license, keepAlive, DistributeLock

For example, path analysis is encapsulated in boot4go-util, which also encapsulates advanced operations related to arrays, and http encapsulates related fasthttp

For example, the operation of json feels that the original json function and performance are very limited, and the boot4go-fastjson is encapsulated on the basis of fastjson

For path mapping, according to the function of antPathMatcher in springboot, golang’s boot4go-Pathmatcher is encapsulated. Golang has native Path and FilePath to provide Match functions, but the performance and functions are really uncomfortable. After encapsulation, the functions and performance All directly kill the original, and the proper flavor of the Java language.

The log, of course, is the log4go of boot4go, which is the same as Logback and Log4j, with a familiar java taste

Project address: github.com/gohutool/boot4g-gateway

Guess you like

Origin blog.csdn.net/inthirties/article/details/126880145