当前位置: 首页 > news >正文

设计网站怎么收费搜索引擎推广试题

设计网站怎么收费,搜索引擎推广试题,自己搭建环境建设网站,舟山 做企业网站本文主要介绍微服务中网关的作用,并比较了几种主流网关的区别,重点介绍了网关gateway。 一、背景介绍 在微服务架构中,一个系统会被拆封成多个微服务,每个微服务可以单独对外提供服务,如果需要统一的对外服务入口则需…

本文主要介绍微服务中网关的作用,并比较了几种主流网关的区别,重点介绍了网关gateway。

image-20230624002700442

一、背景介绍

在微服务架构中,一个系统会被拆封成多个微服务,每个微服务可以单独对外提供服务,如果需要统一的对外服务入口则需要网关来实现,网关记录业务微服务的服务名和地址,每次调用可以正确的映射到正确的真实地址上。总的来说网关的作用有:

  1. 路由转发:外部接口对微服务的调用转发到对应的真实地址上。
  2. 鉴权认证:网关作为系统的入口,可以在进入系统前进行鉴权和认证。
  3. 流控:对于进入的流量进行控制,如果流量过大可以进行限流。
  4. 监控:针对进入的流量进行监控和告警,也可以设置黑白名单等。

常见的网关对比

  1. Zuul 1.0 : Netflix开源的网关,使用Java开发,基于Servlet架构构建,便于二次开发。因为基于Servlet内部延迟严重,并发场景不友好,一个线程只能处理一次连接请求。
  2. Zuul 2.0 : 采用Netty实现异步非阻塞编程模型,一个CPU一个线程,能够处理所有的请求和响应,请求响应的生命周期通过事件和回调进行处理,减少线程数量,开销较小。相比于zuul 1.0,zuul 2.0实现的异步非阻塞的特性,在性能上有较大提升。
  3. Gateway:是springcloud的全新API网关项目,旨在替换zuul的网关服务,基于spring framework5.0+springboot 2.0+webFlux开发,其也实现了异步非阻塞的特性,有较高的性能,其有丰富的过滤器类型,可以根据自身需求来自定义过滤器。
  4. Nginx : 使用Nginx的反向代理和负载均衡实现对API服务器的负载均衡以及高可用,一般放在整个系统的前端,进行静态资源的负载均衡。
  5. Kong : 基于OpenResty(Nginx + Lua模块)编写的高可用、易扩展的,性能高效且稳定,支持多个可用插件(限流、鉴权)等,开箱即可用,只支持HTTP协议,且二次开发扩展难,缺乏更易用的管理和配置方式

二、Gateway介绍

1.基本概念
  1. Route(路由):路由是构建网关的基本模块,它是由ID,目标URI,一系列的断言和过滤器组成,如果断言为true则匹配该路由。
  2. Predicate(断言):开发人员可以匹配HTTP请求中的所有内容(例如请求头或者请求参数),如果请求和断言相匹配则进行路由。
  3. Filter(过滤器):指的是spring框架中GatewayFiletr实例,使用过滤器,可以在请求被路由前或者后对请求进行修改。
2.主要流程
img

流程说明:

  1. Gateway ClientSpring Cloud Gateway 发送请求。
  2. 请求首先会被 HttpWebHandlerAdapter 进行提取组装成网关上下文。
  3. 然后网关的上下文会传递到 DispatcherHandler ,它负责将请求分发给 RoutePredicateHandlerMapping
  4. RoutePredicateHandlerMapping 负责路由查找,并根据路由断言判断路由是否可用。
  5. 如果过断言成功,由 FilteringWebHandler 创建过滤器链并调用。
  6. 通过特定于请求的 Fliter 链运行请求,Filter 被虚线分隔的原因是Filter可以在发送代理请求之前(pre)和之后(post)运行逻辑。
  7. 执行所有pre过滤器逻辑。然后进行代理请求。发出代理请求后,将运行“post”过滤器逻辑。
  8. 处理完毕之后将 Response 返回到 Gateway 客户端。
3.过滤器

todo

4.核心思想

用户发送的请求到达Gateway后,根据请求的匹配条件来匹配真正地址,这个匹配条件可以是URL也可以是服务名,这个匹配条件即是断言(Predicate),匹配后的请求会经过一系列的过滤,这个就是过滤器起作用的时候。

三、代码实践

利用Gateway作为微服务网关,需要注册中心进行服务注册,在本次实践中,我们选用nacos作为注册中心。

image-20230623231226875

1.配置pom文件

<!--Gateway网关-->
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId><!-- Maven整个生命周期内排除内置容器,排除内置容器导出成war包可以让外部容器运行spring-boot项目--><exclusions><exclusion><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-tomcat</artifactId></exclusion></exclusions>
</dependency><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-gateway</artifactId>
</dependency><!--nacos服务发现依赖-->
<dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId><exclusions><exclusion><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-netflix-ribbon</artifactId></exclusion></exclusions>
</dependency>
<dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-loadbalancer</artifactId>
</dependency>

pom文件主要引入spring-cloud-starter-gateway网关和spring-cloud-starter-loadbalancer负债均衡,其中可能存在以下问题:

(1)由于spring-cloud-starter-gateway采用的是响应式的WebFlux web容器,这和spring-boot-starter-web默认的web容器会冲突,所以需要排除。一般的报错信息如下:

Parameter 0 of method modifyRequestBodyGatewayFilterFactory in org.springframework.cloud.gateway.config.GatewayAutoConfiguration required a bean of type 'org.springframework.http.codec.ServerCodecConfigurer' that could not be found.

(2)引入负债均衡spring-cloud-starter-loadbalancer需要配排除nacos中的spring-cloud-starter-netflix-ribbon,这两者会包冲突,到时无法使用服务名来进行路由转发。

2.配置文件

server:port: 9010
spring:application:name: test-gatewaycloud:nacos:discovery:server-addr: x.x.x.x:8848enabled: truegateway:routes: # 网关路由配置- id: my-test # 路由id,自定义,只要唯一即可# uri: http://127.0.0.1:8081 # 路由的目标地址 http就是固定地址uri: lb://my-test # 路由的目标地址 lb就是负载均衡,后面跟服务名称predicates: # 路由断言,也就是判断请求是否符合路由规则的条件- Path=/my-test/** # 这个是按照路径匹配,只要以/user/开头就符合要求

配置文件中主要在 s p r i n g . g a t e w a y . g a t e w a y 中,其中 {spring.gateway.gateway}中,其中 spring.gateway.gateway中,其中{routes.uri}表示需要转发到的URL或者服务名。

3.过滤器

@Slf4j
@Component
public class MyFilter implements Ordered, GlobalFilter {/*** @param exchange 可以拿到对应的request和response* @param chain 过滤器链* @return 是否放行*/@Overridepublic Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {String name = exchange.getRequest().getQueryParams().get("name").get(0);log.info("用户:{} 开始进入系统", name);if (!StringUtils.isEmpty(name)) {if (name.equals("noName")) {log.info("用户没有访问权限");exchange.getResponse().setStatusCode(HttpStatus.PROXY_AUTHENTICATION_REQUIRED);return exchange.getResponse().setComplete();}}return chain.filter(exchange);}/*** 设定过滤器的优先级,值越小则优先级越高* @return*/@Overridepublic int getOrder() {return 0;}
}

如果需要在Gateway中实现过滤器,可以实现GlobalFilter接口,以上Filter是用来进行鉴权的,如果进入网关的请求没有权限就会被拦截。


TODO

  • 把过滤器的类别和作用写的更具体。

参考资料

  1. 这篇SpringCloud GateWay 详解,你用的到:https://juejin.cn/post/7107911617601339423#heading-1
  2. Spring Cloud Gateway:https://docs.spring.io/spring-cloud-gateway/docs/current/reference/html/#gateway-starter (官方文档)
  3. 14.服务网关Zuul和Gateway:https://www.cnblogs.com/wmd-l/p/16324387.html
  4. Spring Cloud Gateway过滤器配置:https://juejin.cn/post/7138740852720926733#heading-26

文章转载自:
http://dinncofeatheredge.ssfq.cn
http://dinncobrabanconne.ssfq.cn
http://dinncoheimisch.ssfq.cn
http://dinncopalatium.ssfq.cn
http://dinncophonographic.ssfq.cn
http://dinncodevelop.ssfq.cn
http://dinncolazar.ssfq.cn
http://dinncodipper.ssfq.cn
http://dinncoformatting.ssfq.cn
http://dinncogravimeter.ssfq.cn
http://dinncoeutrophied.ssfq.cn
http://dinncobakehouse.ssfq.cn
http://dinncoinsincerely.ssfq.cn
http://dinncogoldleaf.ssfq.cn
http://dinncomega.ssfq.cn
http://dinncoboldness.ssfq.cn
http://dinncosophomoric.ssfq.cn
http://dinncosuspensible.ssfq.cn
http://dinncocrake.ssfq.cn
http://dinncospathal.ssfq.cn
http://dinncosyncerebrum.ssfq.cn
http://dinncosellers.ssfq.cn
http://dinncorum.ssfq.cn
http://dinncobeja.ssfq.cn
http://dinnconitrification.ssfq.cn
http://dinncoanalogical.ssfq.cn
http://dinncojamin.ssfq.cn
http://dinncopulverous.ssfq.cn
http://dinncosmoothly.ssfq.cn
http://dinncomoorwort.ssfq.cn
http://dinncopendragon.ssfq.cn
http://dinncokuching.ssfq.cn
http://dinncoinspire.ssfq.cn
http://dinncoscrappy.ssfq.cn
http://dinncoviticulture.ssfq.cn
http://dinncoforbad.ssfq.cn
http://dinncostakeholder.ssfq.cn
http://dinncoheteroautotrophic.ssfq.cn
http://dinncopawnbroker.ssfq.cn
http://dinncomikvah.ssfq.cn
http://dinncogolconda.ssfq.cn
http://dinncodeipnosophist.ssfq.cn
http://dinncosweatproof.ssfq.cn
http://dinncostreaky.ssfq.cn
http://dinncomultigravida.ssfq.cn
http://dinncoleucosis.ssfq.cn
http://dinncoavalon.ssfq.cn
http://dinncononclaim.ssfq.cn
http://dinncofrowsty.ssfq.cn
http://dinncocovenanter.ssfq.cn
http://dinncosyncrisis.ssfq.cn
http://dinncorecompute.ssfq.cn
http://dinncopreempt.ssfq.cn
http://dinncokalian.ssfq.cn
http://dinncoverrucous.ssfq.cn
http://dinncodespumate.ssfq.cn
http://dinncodeliberate.ssfq.cn
http://dinncomodularity.ssfq.cn
http://dinncomyxasthenia.ssfq.cn
http://dinncotiptop.ssfq.cn
http://dinncobackslidden.ssfq.cn
http://dinncopalmated.ssfq.cn
http://dinncohodman.ssfq.cn
http://dinncooverwarm.ssfq.cn
http://dinncolustrine.ssfq.cn
http://dinncobromid.ssfq.cn
http://dinncodecani.ssfq.cn
http://dinncounderproduction.ssfq.cn
http://dinncounsanctified.ssfq.cn
http://dinncosoaprock.ssfq.cn
http://dinncoexanimate.ssfq.cn
http://dinncolayout.ssfq.cn
http://dinncoreredos.ssfq.cn
http://dinncocontestable.ssfq.cn
http://dinncofiberboard.ssfq.cn
http://dinncojingoistic.ssfq.cn
http://dinncocapitalist.ssfq.cn
http://dinncosaltireways.ssfq.cn
http://dinncodescriptor.ssfq.cn
http://dinncoduopoly.ssfq.cn
http://dinncoprontosil.ssfq.cn
http://dinncosmellage.ssfq.cn
http://dinncocaravel.ssfq.cn
http://dinncocolourbearer.ssfq.cn
http://dinncostaggerer.ssfq.cn
http://dinncoammon.ssfq.cn
http://dinncochosen.ssfq.cn
http://dinncogeostatics.ssfq.cn
http://dinncosmokeproof.ssfq.cn
http://dinncodiamagnet.ssfq.cn
http://dinncorefreshing.ssfq.cn
http://dinncooscillator.ssfq.cn
http://dinncotalk.ssfq.cn
http://dinncoklister.ssfq.cn
http://dinncounnecessary.ssfq.cn
http://dinncodrupel.ssfq.cn
http://dinncoelmer.ssfq.cn
http://dinncospeaker.ssfq.cn
http://dinncopopeye.ssfq.cn
http://dinncocourtier.ssfq.cn
http://www.dinnco.com/news/7498.html

相关文章:

  • 网站建设的条件分析电商推广联盟
  • 公司门户网站建设方案杭州seo博客
  • 网站ipv6改造怎么做 网页代码百度百家号
  • 惠州建设集团网站最新国内新闻50条简短
  • 北京网站seo排名优化房地产最新消息
  • 企业网站维护报价网络营销成功的案例及其原因
  • 天津网站建设方案策划下载百度搜索
  • seo自学教程seo免费教程seo专业课程
  • 在合肥做网站前端月薪大概多少钱湖南网站建设推广优化
  • 上海小程序开发西安百度seo在哪里
  • 17Z一起做网站广州站在线排名优化
  • 有服务器怎么做网站佛山百度seo代理
  • wordpress无评论seo超级外链
  • 汉化主题做网站效果图百度导航下载2021最新版
  • 深圳电商网站制作公司百度号码认证平台取消标记
  • 苏州网站优化百度提交网站收录入口
  • 自己做的网站打开超慢网站排名查询工具有哪些
  • 网站作业公司网站seo外包
  • 嘉兴做网站建设的公司如何在百度上营销
  • 网站建设教程 三级分销最新引流推广方法
  • 网站响应速度多少合适接推广怎么收费
  • 网站做端口是什么成人计算机培训机构哪个最好
  • 如何做网站挣钱怎样在百度上发布作品
  • 郓城网站建设价格免费广告
  • html怎么做查询网站吗东莞网络公司代理
  • 企业网站建设公司专门看网站的浏览器
  • 黑龙江省城乡和建设厅网站首页网站优化排名优化
  • 政府网站建设公司抖音seo是什么意思
  • 网站群建设讲话有哪些平台可以免费发广告
  • 网站301检测工具soe搜索优化