spring boot 2:执行器/健康端点需要更多时间 [英] spring boot 2: actuator/health endpoint is taking more time

查看:38
本文介绍了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<的所有 Spring bean 的列表/代码>.

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 入口点 - 调用 http://<host-port>/health 时调用的代码(可能因​​您的设置而异,但您明白了)`,可以找到 这里

If you're looking for the HTTP entry point - the code that gets called when you call http://<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:执行器/健康端点需要更多时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆