spring boot 2:执行器/健康端点需要更多时间

编程入门 行业动态 更新时间:2024-10-23 17:24:58
本文介绍了spring boot 2:执行器/健康端点需要更多时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在我的一个服务/actuator/health 端点中花费了更多时间(大约 9 秒).我正在使用以下依赖项,如何调试?

In one of my service /actuator/health endpoint is taking more time (approximately 9 seconds). I am using following dependencies, how to debug this?

<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <exclusions> <exclusion> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-logging</artifactId> </exclusion> <exclusion> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-jetty</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency>

使用的 Spring Boot 版本: 2.0.3.RELEASE

Spring boot version used: 2.0.3.RELEASE

谢谢,哈里

推荐答案

基本上 health 端点的实现方式是它包含实现接口 HealthIndicator.

Basically health endpoint is implemented in a way that it contains a list of all Spring beans that implement the interface HealthIndicator.

每个健康指标负责提供一个子系统的健康信息(此类子系统的例子有:磁盘、postgres、mongo 等),spring boot 自带一些预定义的健康指标.

Each health indicator is responsible for supplying a health information about one subsystem (examples of such subsystem are:disk, postgres, mongo, etc.), spring boot comes with some predefined HealthIndicators.

这样当 health 端点被调用时,它会遍历这个列表并获取每个子系统的信息,然后构建答案.

So that when the health endpoint is invoked, it iterates through this list and gets the information about each subsystem and then constructs the answer.

因此,您可以在相关的健康指标中放置一个断点(假设您知道检查了哪些子系统),然后看看会发生什么.

Hence you can place a break point in relevant health indicators (assuming you know which subsystems are checked) and see what happens.

如果您正在寻找 HTTP 入口点 - 调用 <host-port>/health 时调用的代码(可能因​​您的设置而异,但您明白了)`,可以找到 这里

If you're looking for the HTTP entry point - the code that gets called when you call <host-port>/health (can vary depending on your settings but you get the idea)`, it can be found here

想到的另一种方法是禁用可疑"程序.健康检查,通过消除找出慢的.

Yet another approach that comes to mind is disabling "suspicious" health check and finding the slow one by elimination.

例如,如果您有一个 Elasticsearch 并想禁用它,请在 application.properties 中使用:

For example, if you have an elastricsearch and would like to disable it, use in the application.properties:

management.health.elasticsearch.enabled = false

更多推荐

spring boot 2:执行器/健康端点需要更多时间

本文发布于:2023-11-26 20:09:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1635012.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:执行器   时间   更多   健康   spring

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!