Gateway selection comparison

1. Why use a gateway

  Different microservices generally have different network addresses, and external clients may need to call multiple service interfaces to fulfill a business requirement. If the client directly communicates with each microservice, there will be the following problems: 1)
  Clients The end will request different microservices multiple times, which increases the complexity of the client.
  2) There are cross-domain requests, and the processing is relatively complicated in certain scenarios.
  3) Authentication is complicated, and each service needs independent authentication
  . Project iterations may require re-dividing microservices
  5) Some microservices may use firewall/browser-unfriendly protocols, and direct access will be difficult. The
  typical gateway architecture is as follows:
insert image description here

2. Comparison of Common Gateways

1. Nginx
1) Processing flow
insert image description here
2) Inter-process communication
insert image description here
2. Zuul
  Zuul is an open source microservice gateway component of Netflix. It can be used in conjunction with Eureka, Ribbon, Hystrix and other components. The core of Zuul is a series of filters. These filters The controller can complete the following functions:
  1) Identity authentication and security: identify the verification requirements of each resource, and reject those requests that do not meet the requirements.
  2) Review and monitoring: Track meaningful data and statistical results with edge locations, thereby bringing accurate production views.
  3) Dynamic routing: dynamically route requests to different backend clusters.
  4) Stress test: Gradually increase traffic to the cluster to understand performance.
  5) Load distribution: allocate corresponding capacity for each load type, and discard requests exceeding the limit value.
  6) Static response processing: Partial responses are built directly at the edge, thereby avoiding their forwarding to the internal cluster.
  7) Multi-region elasticity: Request routing across AWS Regions aims to diversify the use of ELB (Elastic Load Balancing, elastic load balancing) and make the edge of the system closer to the users of the system.
Zuul1: Based on the Servlet framework, it uses blocking and multi-threading methods.
insert image description here
Zuul2: runs on an asynchronous and non-blocking framework, with one thread per CPU core, processing all requests and responses. The life cycle of requests and responses is through events and Callback to handle, this way reduces the number of threads, so the overhead is small. And because the data is stored in the same CPU, the CPU-level cache can be reused
insert image description here
3. Spring Cloud Gateway
  From open source to closed source and then to open source, zull is very unstable externally. Springcloud launched its own gateway springcloud gateway to deal with this unreliability. It uses webflux, and the bottom layer uses netty for asynchronous and callback processing, even for a single node. It supports a large number of concurrent connections, and the business processing logic can be customized based on the Filter mechanism. For details, see the documentation
https://docs.spring.io/spring-cloud-gateway/docs/current/reference/html/#gateway-starter
4 , Kong
  Kong is a high-availability and easy-to-extend API Gateway project open sourced by Mashape based on the Nginx_Lua module. Since Kong is based on Nginx, multiple Kong servers can be expanded horizontally, and requests are evenly distributed to each Server through the pre-load balancing configuration to deal with a large number of network requests. There are three main components: 1) Kong Server
  : Nginx-based server, used to receive API requests
  2) Apache Cassandra/PostgreSQL: used to store operational data
  3) Kong dashboard: Officially recommended UI management tool, of course, you can also manage admin api in a restfull way
  Kong uses a plug-in mechanism for function customization , the set of plugins (can be 0 or n) is executed during the lifecycle of the API request-response cycle. The plug-in is written in Lua and currently has several basic functions: HTTP basic authentication, key authentication, CORS (Cross-origin Resource Sharing, cross-origin resource sharing), TCP, UDP, file logs, API request current limiting, request forwarding and nginx monitoring
  1) Kong official website: https://getkong.org/ plug-in introduction, help documents, etc.
  2) Kong source code: https://github.com/Mashape/kong
  3) Kong UI management tool: https://github.com/PGBI/kong-dashboard browser UI management tool
  4) Kong desktop management tool: https: //github.com/ajaysreedhar/kongdash has linux version, windows version, and mac version.

Related recommendations:
1. Registration center selection comparison
2. Configuration center selection comparison
3. Gateway selection comparison
4. Remote call selection comparison
5. Distributed data consistency
6. Message queue selection comparison
7. Monitoring tool selection Contrast
8. Comparison of full link tracking model selection

Guess you like

Origin blog.csdn.net/qq_21033663/article/details/114046899