网关 zuul 与 spring-cloud gateway的区别


zuul1与spring-cloud-gateway的区别
Zuul:
是netflix公司的项目,本质上是web servlet,基于JavaEE Servlet技术栈,使用阻塞API,处理的是http请求,没有提供异步支持,不支持任何长连接,比如websocket。

依赖:

<dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-zuul</artifactId> </dependency> 

yml配置:

server:
port: 10000
spring:
application:

name: user-service-zuul

eureka:
instance:

prefer-ip-address: true ip-address: 127.0.0.1

client:www.sangpi.com

register-with-eureka: true service-url: defaultZone: 

zuul:
routes:

zuul-path: path: /zuul-path/**

连接:

spring-cloud-gateway:

Spring Boot和Spring Webflux提供的Netty底层环境,不能和传统的Servlety游戏容器一起使用,也不能打包成一个WAR包,使用非阻塞API,支持websocket。

依赖:

<dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-gateway</artifactId> </dependency> 

yml配置:

应用名称

spring:
application:

name: ticket-gateway 

cloud:

nacos: discovery: server-addr: localhost:8848 gateway: routes: - id: user-route uri: lb://user # 负载均衡方式访问user服务 predicates: # 匹配条件 - Path=/api/user/** filters: - StripPrefix=2 

端口

server:
port: 10000

连接:地址/请求路径?参数

watermark,size_14,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_20,type_ZmFuZ3poZW5naGVpdGk=
zuul1与spring-cloud-gateway的区别:

1、gateway对比zuul多依赖了spring-webflux,内部实现了限流、负载均衡等,扩展性也更强,但同时也限制了仅适合于Spring Cloud套件。
zuul则可以扩展至其他微服务框架中,其内部没有实现限流、负载均衡等。
  
2、zuul仅支持同步,
 gateway支持异步。

3、gateway线程开销少,支持各种长连接、websocket,spring官方支持,但运维复杂,
zuul编程模型简单,开发调试运维简单,有线程数限制,延迟堵塞会耗尽线程连接资源。


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM