(十五)springboot电子商务商城之SpringCloud-使用Eureka集群搭建实现高可用服务注册中心

爱吃甜食的少女 2021-04-08 10:07:06
Spring Boot Spring Cloud Eureka


在实际开发过程中,我们可能会不停地重启服务,由于 Eureka 有自己的保护机制,故节点下线后,服务信息还会一直存在于 Eureka 中。我们可以通过增加一些配置让移除的速度更快一点,当然只在开发环境下使用,生产环境下不推荐使用。

首先在我们的 eureka-server 中增加两个配置,分别是关闭自我保护和清理间隔:

eureka.server.enable-self-preservation=false
# 默认 60000 毫秒
eureka.server.eviction-interval-timer-in-ms=5000

然后在具体的客户端服务中配置下面的内容:

eureka.client.healthcheck.enabled=true
# 默认 30 秒
eureka.instance.lease-renewal-interval-in-seconds=5
# 默认 90 秒
eureka.instance.lease-expiration-duration-in-seconds=5

eureka.client.healthcheck.enabled 用于开启健康检查,需要在 pom.xml 中引入 actuator 的依赖,代码如下所示。

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

其中:

  • eureka.instance.lease-renewal-interval-in-seconds 表示 Eureka Client 发送心跳给 server 端的频率。
  • eureka.instance.lease-expiration-duration-in-seconds 表示 Eureka Server 至上一次收到 client 的心跳之后,等待下一次心跳的超时时间,在这个时间内若没收到下一次心跳,则移除该 Instance。

更多的 Instance 配置信息可参考源码中的配置类:org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean。

更多的 Server 配置信息可参考源码中的配置类:org.springframework.cloud.netflix.eureka.server.EurekaServerConfigBean。

推荐布式微服务商城

版权声明
本文为[爱吃甜食的少女]所创,转载请带上原文链接,感谢
https://my.oschina.net/u/5024958/blog/5011710

  1. Zookeeper分布式锁?
  2. Zookeeper distributed lock?
  3. 嵌入式Linux_Framebuffer_03点阵显示ASCII字符串
  4. 嵌入式Linux_Framebuffer_02字符编码
  5. Embedded Linux_ Framebuffer_ 03 dot matrix display ascii string
  6. Embedded Linux_ Framebuffer_ 02 character encoding
  7. Looking forward to new product launch of Xiaomi in spring CNMO takes you to see 11 new products in advance
  8. An inventory of the commonly used garbage collectors in Java
  9. Why is it so easy to get started with HBase?
  10. Implementation of PRC framework based on netty
  11. 2021 Java back end engineer must know knowledge - (Dubbo, distributed RPC framework)
  12. 关于spring advisor和元数据 同时来管理事务的问题
  13. How to manage transactions with spring advisor and metadata at the same time
  14. 使用Playwright对Java API实现自动视觉测试 - applitools
  15. Using playwright to implement automatic visual testing for Java API - applitools
  16. Dubbo和Spring cloud、Istio对比图
  17. Comparison of Dubbo with spring cloud and istio
  18. HttpServletRequest、通过request获得请求头、请求体等、解决中文乱码等问题
  19. Mybatis学习笔记-一对一,一对多,多对多关联查询
  20. Mybatis学习笔记-基本概念与操作
  21. HttpServletRequest, obtaining request header and request body through request, solving Chinese garbled code and other problems
  22. Mybatis learning notes - one to one, one to many, many to many association query
  23. Mybatis learning notes - basic concepts and operation
  24. Spring Cloud 升级之路 - 2020.0.x - 3. Undertow 的 accesslog 配置
  25. Spring cloud upgrade road - 2020.0. X - 3. Accesslog configuration of undertow
  26. 被Java培训机构坑骗后,我在这里找回了自信
  27. After being cheated by java training institutions, I found my confidence here
  28. Linux下安装Mysql出现的常见问题以及解决办法
  29. Common problems and solutions of installing MySQL under Linux
  30. java并发编程JUC第十二篇:AtomicInteger原子整型
  31. Java Concurrent Programming JUC Chapter 12: atomicinteger atomic integer
  32. 面经手册 · 第29篇《Spring IOC 特性有哪些,不会读不懂源码!》
  33. Chapter 29 "what are the features of spring IOC? I can't understand the source code! 》
  34. 浅析linux容器--Docker
  35. Analysis of Linux container -- docker
  36. 换种方法学操作系统,轻松入门Linux内核
  37. 浅析linux容器--Docker
  38. Another way to learn operating system, easy access to Linux kernel
  39. Analysis of Linux container -- docker
  40. 手摸手教你阅读和调试大型开源项目 ZooKeeper
  41. Hand in hand teaching you to read and debug large open source project zookeeper
  42. 基于SpringBoot 在线答题系统 含小程序!
  43. 10个优秀开源JavaScript模板引擎
  44. JavaScript基础知识及写法
  45. Based on springboot online answering system, including small procedures!
  46. 重磅!谷歌Fuchsia操作系统将支持运行Linux应用程序
  47. (四十) springcloud分布式商城之跟我学习SpringCloud-Gateway整合Eureka路由转发
  48. Spring IOC 特性有哪些,不会读不懂源码!
  49. 手摸手教你阅读和调试大型开源项目 ZooKeeper
  50. 10 excellent open source JavaScript template engines
  51. Basic knowledge and writing method of JavaScript
  52. win10安装mysql5.7
  53. Heavy weight! Google's Fuchsia operating system will support running Linux applications
  54. (40) Spring cloud distributed mall learn from me spring cloud gateway integrates Eureka routing and forwarding
  55. What are the spring IOC features? I can't understand the source code!
  56. Hand in hand teaching you to read and debug large open source project zookeeper
  57. Install mysql5.7 in win10
  58. SCIP:构造数据抽象--数据结构中队列与树的解释
  59. Spring Cloud+Nacos实现服务注册中心(Hoxton版本)
  60. rabbitmq-server的安装与升级