在我的一个服务/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:执行器/健康端点需要更多时间
发布评论