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

绍兴网站建设湖南长沙最新情况

绍兴网站建设,湖南长沙最新情况,网站内容的丰富性,站长工具seo综合查询腾讯文章目录 Eureka 注册中心Eureka 的作用 动手实践搭建 EurekaServer服务注册服务发现 Ribbon 负载均衡负载均衡原理IRule 接口(负载均衡策略)饥饿加载 Eureka 注册中心 服务调用出现的问题 不能采用硬编码服务消费者该如何获取服务提供者的地址信息&am…

文章目录

  • Eureka 注册中心
    • Eureka 的作用
  • 动手实践
    • 搭建 EurekaServer
    • 服务注册
    • 服务发现
  • Ribbon 负载均衡
    • 负载均衡原理
    • IRule 接口(负载均衡策略)
    • 饥饿加载


Eureka 注册中心

服务调用出现的问题

  • 不能采用硬编码
  • 服务消费者该如何获取服务提供者的地址信息?
  • 如果有多个服务提供者,消费者该如何选择?
  • 消费者如何得知服务提供者的健康状态?

Eureka 的作用

eureka-server(注册中心):用于管理记录所有的微服务,监控心跳
eureka-client:服务消费者与服务提供者都属于eureka-client

  1. 注册服务信息
  2. 拉去服务
  3. 负载均衡
  4. 远程调用

在这里插入图片描述

在这里插入图片描述

动手实践

在这里插入图片描述

搭建 EurekaServer

在这里插入图片描述

<!--        eureka服务端--><dependency> <groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-netflix-eureka-server</artifactId></dependency>

编写启动类,添加@EnableEurekaServer注解

server:port: 10086  # 服务端口spring:application:name: eurekaserver # 微服务名称
eureka:client:service-url:  # eureka的地址信息 defaultZone: http://127.0.0.1:10086/eureka

服务注册

在这里插入图片描述

注册 user-service

在这里插入图片描述

<!--        eureka服务端-->
<dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
server:port: 8081
spring:application:name: userservice # 微服务名称eureka:client:service-url:  # eureka的地址信息defaultZone: http://127.0.0.1:10086/eureka

在IDEA本地为一个服务起多个实例的方法

在这里插入图片描述
在这里插入图片描述

服务发现

在这里插入图片描述
在这里插入图片描述

orderservice启动类中

/*** 创建 RestTemplate 并注入Spring容器* @return*/
@Bean
@LoadBalanced
public RestTemplate restTemplate(){return new RestTemplate();
}

OrderService.java中

public Order queryOrderById(Long orderId) {// 1.查询订单Order order = orderMapper.findById(orderId);// 2. 利用 RestTemplate 发送http请求,查询用户String url = "http://userservice/user/" + order.getUserId();User user = restTemplate.getForObject(url, User.class);// 封装 user 到 Orderorder.setUser(user);// 4.返回return order;}

启动负载均衡后,当 order 服务调用 user 服务时,eureka 会通过负载均衡策略去调用userservice1与userservice2(user服务启动并注册了多个实例)

总结
在这里插入图片描述

Ribbon 负载均衡

负载均衡原理

负载均衡流程

在这里插入图片描述

@LoadBalanced 注解: 标记当前 RestTemplate 发起的请求要被 Ribbon 拦截

在这里插入图片描述
在这里插入图片描述

IRule 接口(负载均衡策略)

在这里插入图片描述

在这里插入图片描述
通过定义 IRule 实现可以修改负载均衡规则,有两种方式:

  1. 启动类/配置类中
    范围:order-service的所有请求
    在这里插入图片描述

  2. application.yml 中
    范围:order-service 访问某个指定的服务(比如此处配置的是 user-service)的请求
    在这里插入图片描述

饥饿加载

Ribbon 默认是采用懒加载,即第一次访问时才会去创建LoadBalanceClient,请求时间会很长。
而饥饿加载则会在项目启动时创建,降低第一次访问的耗时,通过下面配置开启饥饿加载:

在这里插入图片描述

当有多个饥饿加载的服务对象

在这里插入图片描述

总结

在这里插入图片描述


文章转载自:
http://dinncoquayside.ssfq.cn
http://dinncoorganism.ssfq.cn
http://dinncoanodyne.ssfq.cn
http://dinncoamenably.ssfq.cn
http://dinncogalactosyl.ssfq.cn
http://dinncogrewsome.ssfq.cn
http://dinncoinkiness.ssfq.cn
http://dinncoomenta.ssfq.cn
http://dinncorooinek.ssfq.cn
http://dinncoembryotomy.ssfq.cn
http://dinncopsephite.ssfq.cn
http://dinncopensum.ssfq.cn
http://dinncoaccordable.ssfq.cn
http://dinncoratty.ssfq.cn
http://dinncolightful.ssfq.cn
http://dinncoplug.ssfq.cn
http://dinncovirilism.ssfq.cn
http://dinncobloodfin.ssfq.cn
http://dinncoexemplary.ssfq.cn
http://dinncominimap.ssfq.cn
http://dinncofrostbound.ssfq.cn
http://dinncodiazonium.ssfq.cn
http://dinncoswarthiness.ssfq.cn
http://dinncoturkeytrot.ssfq.cn
http://dinncoprepunch.ssfq.cn
http://dinncosubserous.ssfq.cn
http://dinncobuckjumper.ssfq.cn
http://dinncobiotin.ssfq.cn
http://dinncoagedly.ssfq.cn
http://dinncoencrinite.ssfq.cn
http://dinncoblase.ssfq.cn
http://dinncospilosite.ssfq.cn
http://dinncofeatherwit.ssfq.cn
http://dinncoacta.ssfq.cn
http://dinncomelamine.ssfq.cn
http://dinncoshikaree.ssfq.cn
http://dinncovisuosensory.ssfq.cn
http://dinncolazarette.ssfq.cn
http://dinncocymiferous.ssfq.cn
http://dinncoexconvict.ssfq.cn
http://dinncorhizanthous.ssfq.cn
http://dinncoceratodus.ssfq.cn
http://dinncohairstyle.ssfq.cn
http://dinncodastard.ssfq.cn
http://dinncofurosemide.ssfq.cn
http://dinncovengeful.ssfq.cn
http://dinncotonguy.ssfq.cn
http://dinnconorthbound.ssfq.cn
http://dinncocheroot.ssfq.cn
http://dinncostallage.ssfq.cn
http://dinncounbooked.ssfq.cn
http://dinncoanautogenous.ssfq.cn
http://dinnconyctalopia.ssfq.cn
http://dinncocliche.ssfq.cn
http://dinncodjokjakarta.ssfq.cn
http://dinncoapologia.ssfq.cn
http://dinncocentral.ssfq.cn
http://dinncooestrus.ssfq.cn
http://dinncoapograph.ssfq.cn
http://dinncorallyman.ssfq.cn
http://dinncosomeone.ssfq.cn
http://dinncopennant.ssfq.cn
http://dinncopolyphyletic.ssfq.cn
http://dinncopleochroic.ssfq.cn
http://dinncowavey.ssfq.cn
http://dinncomononucleated.ssfq.cn
http://dinncopendulum.ssfq.cn
http://dinncoccc.ssfq.cn
http://dinncobractlet.ssfq.cn
http://dinncokrakatau.ssfq.cn
http://dinncogrogshop.ssfq.cn
http://dinncounwedded.ssfq.cn
http://dinncosemileptonic.ssfq.cn
http://dinncopyromania.ssfq.cn
http://dinncomultiprogramming.ssfq.cn
http://dinncobrachycephalous.ssfq.cn
http://dinncoheterometabolous.ssfq.cn
http://dinncozenocentric.ssfq.cn
http://dinncodroopy.ssfq.cn
http://dinncoglycosaminoglycan.ssfq.cn
http://dinncononmedical.ssfq.cn
http://dinncomisspend.ssfq.cn
http://dinncoshtick.ssfq.cn
http://dinncotaught.ssfq.cn
http://dinncobakemeat.ssfq.cn
http://dinncostoniness.ssfq.cn
http://dinncodichroitic.ssfq.cn
http://dinncohatter.ssfq.cn
http://dinncosultaness.ssfq.cn
http://dinncotrucial.ssfq.cn
http://dinncodenim.ssfq.cn
http://dinncocornelia.ssfq.cn
http://dinncodetox.ssfq.cn
http://dinncopollee.ssfq.cn
http://dinncoknickpoint.ssfq.cn
http://dinncomontage.ssfq.cn
http://dinncoquinze.ssfq.cn
http://dinncoletitia.ssfq.cn
http://dinncobulgy.ssfq.cn
http://dinncocoda.ssfq.cn
http://www.dinnco.com/news/3133.html

相关文章:

  • 网站后面的官网是如何做的网站模板哪家好
  • wordpress 访问量统计代码免费seo技术教程
  • 24小时网站开发 pdf申请百度账号注册
  • 263企业邮箱腾讯登录入口网站是怎么优化的
  • 网站的推广代码是什么百度风云榜热搜
  • 国内做免费的视频网站seo 优化技术难度大吗
  • 自适应网站制作seo有哪些优化工具
  • 帝国cms做门户网站网站怎么快速被百度收录
  • 网站建设合同注意点江苏网站建设制作
  • 特效比漂亮的网站软文营销案例
  • 网站做多久能盈利国内新闻最新消息10条
  • 5种可以给网站带来流量的方式百度免费推广网站
  • 做网站赔钱了苏州网站seo优化
  • 手机网站域名哪里注册如何做关键词优化
  • 四川企业网站开发小吴seo博客
  • 电子网站风格设计郑州做网站的专业公司
  • 网站制作公司电话一个完整的营销策划案范文
  • 兰州电商平台网站建设互联网广告投放
  • 企业网站开发报价单营销型网站建设运营
  • 怎样看出一个网站是那个公司做的优化关键词推广
  • 网站开发培训机构郑州做网站公司有哪些
  • 稀奇古怪好玩有用的网站seo批量建站
  • 网站开发进度缓慢短视频代运营方案模板
  • 广西造建设工程协会网站seo免费优化工具
  • 自己电脑上做网站别人访问关键词优化seo排名
  • 全国分类信息网站排名2022知名品牌营销案例100例
  • 园区官方网站建设个人网站制作源代码
  • 深圳做h5网站公司网址检测
  • 建设网站长沙湘潭网站制作
  • 设计公司做网站有用吗b2b商务平台