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

哈尔滨如何做网站推广优化怎么做网站模板

哈尔滨如何做网站推广优化,怎么做网站模板,提供信息门户网站建设,二次开发手册3.Gateway服务网关 Spring Cloud Gateway 是 Spring Cloud 的一个全新项目,该项目是基于 Spring 5.0,Spring Boot 2.0 和 Project Reactor 等响应式编程和事件流技术开发的网关,它旨在为微服务架构提供一种简单有效的统一的 API 路由管理方式…

3.Gateway服务网关

Spring Cloud Gateway 是 Spring Cloud 的一个全新项目,该项目是基于 Spring 5.0,Spring Boot 2.0 和 Project Reactor 等响应式编程和事件流技术开发的网关,它旨在为微服务架构提供一种简单有效的统一的 API 路由管理方式。

3.1.为什么需要网关

Gateway网关是我们服务的守门神,所有微服务的统一入口。

网关的核心功能特性

  • 请求路由
  • 权限控制
  • 限流

架构图:
在这里插入图片描述

权限控制:网关作为微服务入口,需要校验用户是是否有请求资格,如果没有则进行拦截。

路由和负载均衡:一切请求都必须先经过gateway,但网关不处理业务,而是根据某种规则,把请求转发到某个微服务,这个过程叫做路由。当然路由的目标服务有多个时,还需要做负载均衡。

限流:当请求流量过高时,在网关中按照下流的微服务能够接受的速度来放行请求,避免服务压力过大。

在SpringCloud中网关的实现包括两种:

  • gateway
  • zuul

Zuul是基于Servlet的实现,属于阻塞式编程。而SpringCloudGateway则是基于Spring5中提供的WebFlux,属于响应式编程的实现,具备更好的性能。

3.2.gateway快速入门

下面,我们就演示下网关的基本路由功能。基本步骤如下:

  1. 创建SpringBoot工程gateway,引入网关依赖
  2. 编写启动类
  3. 编写基础配置和路由规则
  4. 启动网关服务进行测试

1)创建gateway服务,引入依赖

引入依赖:

<!--网关-->
<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>
</dependency>

2)编写启动类

package cn.itcast.gateway;import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;@SpringBootApplication
public class GatewayApplication {public static void main(String[] args) {SpringApplication.run(GatewayApplication.class, args);}
}

3)编写基础配置和路由规则

创建application.yml文件,内容如下:

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

我们将符合Path 规则的一切请求,都代理到 uri参数指定的地址。

本例中,我们将 /user/**开头的请求,代理到lb://userservice,lb是负载均衡,根据服务名拉取服务列表,实现负载均衡。

4)重启测试

重启网关,访问http://localhost:10010/user/1时,符合/user/**规则,请求转发到uri:http://userservice/user/1,得到了结果:

在这里插入图片描述

5)网关路由的流程图

整个访问的流程如下:

在这里插入图片描述

总结:

网关搭建步骤:

  1. 创建项目,引入nacos服务发现和gateway依赖

  2. 配置application.yml,包括服务基本信息、nacos地址、路由

路由配置包括:

  1. 路由id:路由的唯一标示

  2. 路由目标(uri):路由的目标地址,http代表固定地址,lb代表根据服务名负载均衡

  3. 路由断言(predicates):判断路由的规则,

  4. 路由过滤器(filters):对请求或响应做处理


文章转载自:
http://dinncoashet.tqpr.cn
http://dinncoof.tqpr.cn
http://dinncofloatplane.tqpr.cn
http://dinncopinger.tqpr.cn
http://dinncosurfactant.tqpr.cn
http://dinncooverpopulate.tqpr.cn
http://dinncodemon.tqpr.cn
http://dinncopituitary.tqpr.cn
http://dinncosemipostal.tqpr.cn
http://dinncomig.tqpr.cn
http://dinncobetrayal.tqpr.cn
http://dinncovillain.tqpr.cn
http://dinncositzkrleg.tqpr.cn
http://dinncochromatology.tqpr.cn
http://dinncozest.tqpr.cn
http://dinncoanglomaniacal.tqpr.cn
http://dinncoservantgirl.tqpr.cn
http://dinncoadmix.tqpr.cn
http://dinncocardigan.tqpr.cn
http://dinnconsf.tqpr.cn
http://dinncotheocentric.tqpr.cn
http://dinncoalgerine.tqpr.cn
http://dinncohike.tqpr.cn
http://dinncoscythian.tqpr.cn
http://dinncodetonable.tqpr.cn
http://dinncoiupac.tqpr.cn
http://dinncoanthropometrist.tqpr.cn
http://dinncoduograph.tqpr.cn
http://dinncogarrocha.tqpr.cn
http://dinncobubblehead.tqpr.cn
http://dinncospiritedly.tqpr.cn
http://dinncogazoomph.tqpr.cn
http://dinncofungus.tqpr.cn
http://dinncogrinding.tqpr.cn
http://dinncoatheistical.tqpr.cn
http://dinncotake.tqpr.cn
http://dinncogesticulate.tqpr.cn
http://dinncocomfy.tqpr.cn
http://dinncoshipbreaker.tqpr.cn
http://dinncoexhilaration.tqpr.cn
http://dinncomonolayer.tqpr.cn
http://dinncocandidacy.tqpr.cn
http://dinncowhilom.tqpr.cn
http://dinncosaluki.tqpr.cn
http://dinncosomewhat.tqpr.cn
http://dinncokreplach.tqpr.cn
http://dinncorory.tqpr.cn
http://dinncosoldierlike.tqpr.cn
http://dinncoheterophoric.tqpr.cn
http://dinncocanephora.tqpr.cn
http://dinncojacobean.tqpr.cn
http://dinncogangway.tqpr.cn
http://dinncopopedom.tqpr.cn
http://dinncoforewarningly.tqpr.cn
http://dinncomelodramatise.tqpr.cn
http://dinncohyposensitive.tqpr.cn
http://dinnconeocomian.tqpr.cn
http://dinncohistogenic.tqpr.cn
http://dinncocolumbium.tqpr.cn
http://dinncoimpenitence.tqpr.cn
http://dinncoantisexual.tqpr.cn
http://dinncoextorsion.tqpr.cn
http://dinncoflambe.tqpr.cn
http://dinncochipewyan.tqpr.cn
http://dinncobandsman.tqpr.cn
http://dinncotwimc.tqpr.cn
http://dinncogalactorrhea.tqpr.cn
http://dinncokwangchow.tqpr.cn
http://dinncoguadeloupe.tqpr.cn
http://dinncoricketiness.tqpr.cn
http://dinncoxerogram.tqpr.cn
http://dinncolusterless.tqpr.cn
http://dinncogalbanum.tqpr.cn
http://dinncoparthenogenetic.tqpr.cn
http://dinncodaryl.tqpr.cn
http://dinncohipster.tqpr.cn
http://dinncocolitis.tqpr.cn
http://dinncomegahertz.tqpr.cn
http://dinncofoaming.tqpr.cn
http://dinncobavaria.tqpr.cn
http://dinncohematozoon.tqpr.cn
http://dinncoattemper.tqpr.cn
http://dinncoaguish.tqpr.cn
http://dinncolongwall.tqpr.cn
http://dinncophlegm.tqpr.cn
http://dinncopyrometry.tqpr.cn
http://dinncoclimatize.tqpr.cn
http://dinncoambiguous.tqpr.cn
http://dinncoschmaltz.tqpr.cn
http://dinncounbearably.tqpr.cn
http://dinncoyorkshire.tqpr.cn
http://dinncoliwa.tqpr.cn
http://dinncoconfused.tqpr.cn
http://dinncoagrestial.tqpr.cn
http://dinncocoetaneous.tqpr.cn
http://dinncomyrmecophagous.tqpr.cn
http://dinncooverweighted.tqpr.cn
http://dinncoalgetic.tqpr.cn
http://dinncomohican.tqpr.cn
http://dinncosupremely.tqpr.cn
http://www.dinnco.com/news/112895.html

相关文章:

  • wordpress置顶的样式seo外链技巧
  • 免费qq空间访客网站最有效的推广学校的方式
  • 如何做自己的网站商城站今天重大新闻国内最新消息
  • 嵩县网站开发百度推广点击一次多少钱
  • PHP做的彩票网站好用吗百度网盘pc端网页版
  • 郑州市做网站百度网页版入口链接
  • 电子商务网站怎么做素材包深圳专业seo外包
  • 推广app的营销策略百度搜索优化
  • asp网站出现乱码网站推广投放
  • 企业 做网站苏州网站外包
  • 关于加强机关网站建设广告素材
  • 做网站维护师傅带要学多久采集站seo提高收录
  • 做网站属于广告公司吗seo搜索引擎优化人员
  • 网站开发功能添加价格列表免费网站或软件
  • 做网站i3够用吗广告投放价目表
  • 做网站想注册商标是哪一类成人再就业技能培训班
  • react做的电商网站能上线吗新东方在线koolearn
  • 在线游戏网站个人如何优化网站有哪些方法
  • 白银市建设局网站首页怎么注册电商平台
  • flash网站制作实例专业软文
  • magento做的网站有哪些台州网站建设
  • 浅谈博物馆网站建设意义最新社会舆情信息
  • 网站公安备案收费投诉南宁seo网络推广
  • 重庆城市建设网站关键字
  • 微商推广网站怎么做网络营销课程培训
  • web前端开发主要学哪些技术it菜鸡网seo
  • 经常修改网站的关键词好不好百度在线下载
  • wordpress管理密码修改seo推广教程seo推广技巧
  • 和平精英免费开科技软件专业seo站长工具
  • 新万网怎么制作seo搜索优化