spring cloud 中的负载均衡有ribbon和feign

引入ribbon依赖

        <!--ribbon相关-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-ribbon</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>

在客户端加入loadblance

     @Bean
@LoadBalanced //ribbon负载均衡,
public RestTemplate getRestaTemplate(){
return new RestTemplate();
}

ribbon的负载均衡算法有七种,默认轮询,要更换:

   @Bean
@LoadBalanced //ribbon负载均衡,
public RestTemplate getRestaTemplate(){
return new RestTemplate();
} //更换算法
@Bean
public IRule defRule(){
return new RandomRule();
}

自定义Rule,不能建在与主类及子包下面:

@SpringBootApplication
@EnableEurekaClient
@RibbonClient(name = "MICROSERVICECLOUD",configuration = "自定义的rule")
public class Consumer80 {
public static void main(String[] args) {
SpringApplication.run(Consumer80.class,args);
}
}

ribbon学习的更多相关文章

  1. springcloud Ribbon学习笔记二

    之前介绍了如何搭建eureka服务并开发了一个用户服务成功注册到了eureka中,接下来介绍如何通过ribbon来从eureka中获取用户服务: springcloud ribbon提供客户端的负载均 ...

  2. springcloud Ribbon学习笔记一

    上篇已经介绍了如何开发eureka服务并让多个服务进行相互注册,接下来记录如何开发一个服务然后注册到eureka中并能通过ribbon成功被调用 开发一个用户服务并注册到eureka中,用户服务负责访 ...

  3. Ribbon学习笔记

    微服务的概念: Ribbon默认的是轮询的算法:   @LoadBalanced @EnableEurekaClient Irule是根据 Ribbon默认(轮询)的7中负载均衡的算法: 修改默认的R ...

  4. Spring Cloud Feign 调用过程分析

    前面已经学习了两个Spring Cloud 组件: Eureka:实现服务注册功能: Ribbon:提供基于RestTemplate的HTTP客户端并且支持服务负载均衡功能. 通过这两个组件我们暂时可 ...

  5. VSTO 学习笔记(十二)自定义公式与Ribbon

    原文:VSTO 学习笔记(十二)自定义公式与Ribbon 这几天工作中在开发一个Excel插件,包含自定义公式,根据条件从数据库中查询结果.这次我们来做一个简单的测试,达到类似的目的. 即在Excel ...

  6. VSTO 学习笔记(十)Office 2010 Ribbon开发

    原文:VSTO 学习笔记(十)Office 2010 Ribbon开发 微软的Office系列办公套件从Office 2007开始首次引入了Ribbon导航菜单模式,其将一系列相关的功能集成在一个个R ...

  7. SpringCloud学习之Ribbon

    一.负载均衡与Ribbon 负载均衡,在集群中是很常见的一个“名词”,顾名思义是根据一定的算法将请求分摊至对应的服务节点上,常见的算法有如下几种: 轮询法:所有请求被依次分发到每台应用服务器上,每台服 ...

  8. 【SpringCloud微服务实战学习系列】客户端负载均衡Spring Cloud Ribbon

    Spring Cloud Ribbon是一个基于HTTP和TCP的客户端负载均衡工具,它基于Netflix Ribbon实现.通过Spring Cloud的封装,可以让我们轻松地将面向服务的RES模板 ...

  9. SpringCloud学习:Eureka、Ribbon和Feign

    Talk is cheap,show me the code , 书上得来终觉浅,绝知此事要躬行.在自己真正实现的过程中,会遇到很多莫名其妙的问题,而正是在解决这些问题的过程中,你会发现自己之前思维的 ...

随机推荐

  1. ldd3 编写scull尝试

    快速参考: #include <linux/types.h> dev_t dev_t is the type used to represent device numbers within ...

  2. k-近邻算法(kNN)笔记

    #mat()函数可以将数组(array)转化为矩阵(matrix)# randMat = mat(random.rand(4,4))# 求逆矩阵:randMat.I# 存储逆矩阵:invRandMat ...

  3. 第七周编程总结&&实验报告五

    实验四 类的继承 实验目的 理解抽象类与接口的使用: 了解包的作用,掌握包的设计方法 实验要求 掌握使用抽象类的方法. 掌握使用系统接口的技术和创建自定义接口的方法. 了解 Java 系统包的结构. ...

  4. SSAS MDX语句 期末查询简单示例

    WITH Member [Measures].[num Last Day of Month] AS( [时间].[YQMD].CurrentMember.LastChild,[Measures].[门 ...

  5. 用 Flask 来写个轻博客 (31) — 使用 Flask-Admin 实现 FileSystem 管理

    Blog 项目源码:https://github.com/JmilkFan/JmilkFan-s-Blog 目录 目录 前文列表 扩展阅读 编写 FileSystem Admin 页面 Flask-A ...

  6. linux在二进制文件中查找pattern的offset

    参考:http://stackoverflow.com/questions/14141008/grep-offset-of-ascii-string-from-binary-file strings ...

  7. div里添加元素样式

    function YUEFEN() { $(".BBNL_2").click(function () { $(".BBNL_2").css("colo ...

  8. MSF——Meterpreter(三)

    MSF系列: MSF——基本使用和Exploit模块(一) MSF——Payload模块(二) MSF——Meterpreter(三) MSF——信息收集(四) 一.简介 Meterpreter是Me ...

  9. 厉害了,Java EE 再次更名为 Jakarta EE

    来自:开源中国 https://www.oschina.net/news/108108/java-ee-rename-as-jakarta-ee Eclipse基金会最近对 Java EE 标准的每个 ...

  10. canvas时间粒子

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...