首页 \ 问答 \ 了解Spring Cloud Eureka服务器自我保护和更新阈值(Understanding Spring Cloud Eureka Server self preservation and renew threshold)

了解Spring Cloud Eureka服务器自我保护和更新阈值(Understanding Spring Cloud Eureka Server self preservation and renew threshold)

我是开发微服务的新手,虽然我一直在研究一段时间,阅读Spring的文档和Netflix的文档。

我已经开始在Github上提供一个简单的项目。 它基本上是一个尤里卡服务器(阿基米德)和三个尤里卡客户端微服务器(一个公共API和两个私有的)。 检查github的自述文件是否有详细描述。

关键是当一切正在运行时,我希望如果其中一个私有微服务被杀死,则Eureka服务器实现并将其从注册表中删除。

我在Stackoverflow中发现了这个问题 ,解决方案通过在Eureka服务器配置中使用enableSelfPreservation:false 。 一段时间以后,这样做会使被杀的服务像预期的那样消失。

但是我可以看到以下消息:

自动保存模式被关闭,此时可能不会在网络/其他问题的情况下保护实时。

1.自我保护的目的是什么? 该文档指出,对“客户端可以获取不再存在的实例”进行自我保护。 那么什么时候可以开/关?

此外,当自我保存开启时,您可能会在Eureka服务器控制台警告中收到一个很好的信息:

紧急! EUREKA可能不正当地要求他们在他们没有的情况下。 重新获得的利润低于此价格,并且这个价格不会过期,只能安全。

现在,继续使用Spring Eureka控制台。

Lease expiration enabled    true/false
Renews threshold    5
Renews (last min)   4

我遇到了一个奇怪的阈值行为:当我单独启动Eureka服务器时,阈值为1。

2.我有一个单一的Eureka服务器,并配置了registerWithEureka: false以防止在另一个服务器上注册。 那么为什么它出现在门槛数?

3.对于每个客户端,我开始阈值增加+2。 我猜是因为他们每分钟发送2条续订邮件,对不对?

尤里卡服务器永远不会发送更新,所以最后一分钟更新始终低于阈值。 这是正常吗?

renew threshold 5
rewnews last min: (client1) +2 + (client2) +2 -> 4

服务器cfg:

server:
  port: ${PORT:8761}

eureka:
  instance:
    hostname: localhost
  client:
    registerWithEureka: false
    fetchRegistry: false
    serviceUrl:
      defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
  server:
    enableSelfPreservation: false
#   waitTimeInMsWhenSyncEmpty: 0

客户1 cfg:

spring:
  application:
    name: random-image-microservice

server:
  port: 9999

eureka:
  client:
    serviceUrl:
      defaultZone: http://localhost:8761/eureka/
    healthcheck:
      enabled: true

I am new to developing microservices, although I have been researching about it for a while, reading both Spring's docs and Netflix's.

I have started a simple project available on Github. It is basically a Eureka server (Archimedes) and three Eureka client microservices (one public API and two private). Check github's readme for a detailed description.

The point is that when everything is running I would like that if one of the private microservices is killed, the Eureka server realizes and removes it from the registry.

I found this question on Stackoverflow, and the solution passes by using enableSelfPreservation:false in the Eureka Server config. Doing this after a while the killed service disappears as expected.

However I can see the following message:

THE SELF PRESERVATION MODE IS TURNED OFF.THIS MAY NOT PROTECT INSTANCE EXPIRY IN CASE OF NETWORK/OTHER PROBLEMS.

1. What is the purpose of the self preservation? The doc states that with self preservation on "clients can get the instances that do not exist anymore". So when is it advisable to have it on/off?

Furthermore, when self preservation is on, you may get an outstanding message in the Eureka Server console warning:

EMERGENCY! EUREKA MAY BE INCORRECTLY CLAIMING INSTANCES ARE UP WHEN THEY'RE NOT. RENEWALS ARE LESSER THAN THRESHOLD AND HENCE THE INSTANCES ARE NOT BEING EXPIRED JUST TO BE SAFE.

Now, going on with the Spring Eureka Console.

Lease expiration enabled    true/false
Renews threshold    5
Renews (last min)   4

I have come across a weird behaviour of the threshold count: when I start the Eureka Server alone, the threshold is 1.

2. I have a single Eureka server and is configured with registerWithEureka: false to prevent it from registering on another server. Then, why does it show up in the threshold count?

3. For every client I start the threshold count increases by +2. I guess it is because they send 2 renew messages per min, am I right?

4. The Eureka server never sends a renew so the last min renews is always below the threshold. Is this normal?

renew threshold 5
rewnews last min: (client1) +2 + (client2) +2 -> 4

Server cfg:

server:
  port: ${PORT:8761}

eureka:
  instance:
    hostname: localhost
  client:
    registerWithEureka: false
    fetchRegistry: false
    serviceUrl:
      defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
  server:
    enableSelfPreservation: false
#   waitTimeInMsWhenSyncEmpty: 0

Client 1 cfg:

spring:
  application:
    name: random-image-microservice

server:
  port: 9999

eureka:
  client:
    serviceUrl:
      defaultZone: http://localhost:8761/eureka/
    healthcheck:
      enabled: true

原文:https://stackoverflow.com/questions/33921557
更新时间:2023-05-06 20:05

最满意答案

这个问题似乎是我没有把错误当作可选的。 以下工作:

var error: NSError?
NSException.raise("Exception", format:"Error: %@", arguments:getVaList([error!]))

或者,如果错误为零,您可以执行以下操作:

NSException.raise("Exception", format:"Error: %@", arguments:getVaList([error ?? "nil"]))

The problem seems to have been that I didn't treat the error as an optional. The following works:

var error: NSError?
NSException.raise("Exception", format:"Error: %@", arguments:getVaList([error!]))

Or you could do the following in case error is nil:

NSException.raise("Exception", format:"Error: %@", arguments:getVaList([error ?? "nil"]))

相关问答

更多
  • 这个问题似乎是我没有把错误当作可选的。 以下工作: var error: NSError? NSException.raise("Exception", format:"Error: %@", arguments:getVaList([error!])) 或者,如果错误为零,您可以执行以下操作: NSException.raise("Exception", format:"Error: %@", arguments:getVaList([error ?? "nil"])) The problem see ...
  • 问题是n是包装的: var n:Int? 所以你有几个选项,你可以改变你的代码来在你使用它时打开它(在这之前检查nil可能是一个好主意,因为如果n是nil会导致异常): var vypoctenaZavorka = mocnina(mocnenec: zavorka, mocnitel: n!) 或者您可以在创建它时将其解包: let n:Int = dobaSplaceni.text.toInt()! 如果你想更好地理解“何时使用选项”,我就这个问题写了一个很长的解释: UIViewControll ...
  • 这是一些代码,将NSExceptions转换为Swift 2错误。 现在可以使用 do { try ObjC.catchException { /* calls that might throw an NSException */ } } catch { print("An error ocurred: \(error)") } ObjC.h: #import @interface ObjC : NSObject ...
  • 连接字符串时,很容易错过简单的符号。 在这种情况下,您可以修改添加\n和+到具有set output的行: "set output \"1.png\"\n" + 我们的想法是创建一个字符串,就好像我们在gnuplot shell中写的一样,所以每个\n我们模拟一个新行,并且每个+我们连接两个或更多字符串...... 这甚至是gnuplot脚本的基础。 经常用gnuplot编写一个外部脚本并加载它 load "myscript.gnuplot" 或运行它 gnuplot -persist mysc ...
  • 在ViewController添加以下行将解决您的问题。 @IBOutlet weak var enterButton: UIButton! 由于ViewController与storyboard文件中的三个IBOutlet连接,因此发生错误。 你在ViewController.swift文件中只写了两个IBOutlet作为IBOutlet 。 你错过了写enterButton IBOutlet 。 而已。 Adding the below line in the ViewController will ...
  • 正如Andrea所说 ,你应该在viewDidLoad实例化计时器。 另外文档说 : 选择器应该具有以下签名: timerFireMethod:包括用于指示该方法接受参数的冒号)。 并且不要忘记在例如viewDidDisappear禁用此计时器。 您不能在deinit invalidate ,因为重复计时器会保持对其目标的强引用,并且只要计时器正在运行,您的deinit就不会被调用。 如果你在viewDidDisappear删除它,你可能想在viewDidAppear创建定时器。 因此,导致如下所示: cl ...
  • 这是值类型陷阱 。 Swift集合类型是具有值语义的结构,与具有引用语义的类不同。 line var tableSection = self.sections[self.sortedSections[indexPath.section]]制作对象的副本并保持self.sections不变。 从列表中删除项目后,您必须将数组分配回self.sections 。 tableSection?.removeAtIndex(indexPath.row) self.sections[self.sortedSection ...
  • 已经为新的#selector()弃用了字符串类型的Selector() #selector() 。 将您的操作更新为#selector(gesture(gesture:)) ,这应该修复它 let swipeRight = UISwipeGestureRecognizer(target: self, action: #selector(gesture(gesture:))) swipeRight.direction = UISwipeGestureRecognizerDirection.right self ...
  • 您好我发现您的问题并在此处修复。 问题是你从未跟随Swift 3风格的方法调用KVO自Swift 3以来,方法原型已被更改。 你的代码在这里: func observeValueForKeyPath(keyPath: String?, ofObject object: AnyObject?, change: [String : AnyObject]?, context: UnsafeMutableRawPointer) { let textView = object as! UITextVi ...
  • 只需删除不再需要它的takeRetainedValue()。 var reachability = SCNetworkReachabilityCreateWithName(kCFAllocatorDefault, "www.apple.com") Just remove the takeRetainedValue() you don't need it anymore. var reachability = SCNetworkReachabilityCreateWithName(kCFAllocatorD ...

相关文章

更多

最新问答

更多
  • h2元素推动其他h2和div。(h2 element pushing other h2 and div down. two divs, two headers, and they're wrapped within a parent div)
  • 创建一个功能(Create a function)
  • 我投了份简历,是电脑编程方面的学徒,面试时说要培训三个月,前面
  • PDO语句不显示获取的结果(PDOstatement not displaying fetched results)
  • Qt冻结循环的原因?(Qt freezing cause of the loop?)
  • TableView重复youtube-api结果(TableView Repeating youtube-api result)
  • 如何使用自由职业者帐户登录我的php网站?(How can I login into my php website using freelancer account? [closed])
  • SQL Server 2014版本支持的最大数据库数(Maximum number of databases supported by SQL Server 2014 editions)
  • 我如何获得DynamicJasper 3.1.2(或更高版本)的Maven仓库?(How do I get the maven repository for DynamicJasper 3.1.2 (or higher)?)
  • 以编程方式创建UITableView(Creating a UITableView Programmatically)
  • 如何打破按钮上的生命周期循环(How to break do-while loop on button)
  • C#使用EF访问MVC上的部分类的自定义属性(C# access custom attributes of a partial class on MVC with EF)
  • 如何获得facebook app的publish_stream权限?(How to get publish_stream permissions for facebook app?)
  • 如何防止调用冗余函数的postgres视图(how to prevent postgres views calling redundant functions)
  • Sql Server在欧洲获取当前日期时间(Sql Server get current date time in Europe)
  • 设置kotlin扩展名(Setting a kotlin extension)
  • 如何并排放置两个元件?(How to position two elements side by side?)
  • 如何在vim中启用python3?(How to enable python3 in vim?)
  • 在MySQL和/或多列中使用多个表用于Rails应用程序(Using multiple tables in MySQL and/or multiple columns for a Rails application)
  • 如何隐藏谷歌地图上的登录按钮?(How to hide the Sign in button from Google maps?)
  • Mysql左连接旋转90°表(Mysql Left join rotate 90° table)
  • dedecms如何安装?
  • 在哪儿学计算机最好?
  • 学php哪个的书 最好,本人菜鸟
  • 触摸时不要突出显示表格视图行(Do not highlight table view row when touched)
  • 如何覆盖错误堆栈getter(How to override Error stack getter)
  • 带有ImageMagick和许多图像的GIF动画(GIF animation with ImageMagick and many images)
  • USSD INTERFACE - > java web应用程序通信(USSD INTERFACE -> java web app communication)
  • 电脑高中毕业学习去哪里培训
  • 正则表达式验证SMTP响应(Regex to validate SMTP Responses)