Spring boot:用于在管理端口上服务请求的线程池 [英] Spring boot : Thread pool for serving requests on Management port

查看:24
本文介绍了Spring boot:用于在管理端口上服务请求的线程池的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Kubernetes 集群中运行时,我们使用 Spring Boot 执行器来公开活动和就绪端点.默认情况下,spring-boot 执行器在默认标准 HTTP 服务器端口上公开端点,其中请求由 Tomcat/Jetty 服务器接受器和工作线程池提供服务.我们最近在压力测试期间遇到了一个问题,即工作池中的所有线程都很忙,新请求正在排队.这导致 Pod 在 Kubernetes 集群中崩溃,因为活性探针开始失败.

We are using a spring boot actuator for exposing liveness and readiness endpoints when running in the Kubernetes cluster. By default, the spring-boot actuator exposes the endpoint on the default standard HTTP server port where the request is served by Tomcat/Jetty server acceptor and worker thread pools. We recently ran into an issue during our stress testing where all threads in the worker pool were busy and new requests were getting queued. This caused the pod to crash in the Kubernetes cluster as the liveness probes started failing.

我正在考虑在管理端口上暴露执行器.我想检查以下内容

I am considering exposing the actuator on the management port. I wanted to check on the following

a) 管理端口上的请求是否服务于单独的工作线程池(与标准服务器端口的工作线程池不同)?

a) Are the requests on the management port served a separate worker thread pool (from that of the standard server port )?

b) 如果 a) 的答案是否定的,有没有办法可以配置 Spring Boot 以使用单独的线程池作为管理端口(我们在不同的微服务中使用 tomcat/jetty 和反应式 netty 服务器)

b) If the answer to a) is no, is there a way I can configure spring boot to use a separate thread pool for management port (we are using tomcat/jetty and reactive netty servers across our different micro services)

推荐答案

是的,如果您指定不同的管理端口,Spring/Tomcat 将使用单独的线程池来为该端口上的请求提供服务.

Yes, if you specify a different management port, Spring/Tomcat will be using a separate thread pool for serving requests on that port.

例如如果你指定这样的东西是你的配置:

E.g. if you specify something like this is your configuration:

server.port=8080
management.server.port=8081
server.tomcat.threads.max=10

端口 8080 上的常规请求将由来自标准线程池的线程提供服务,该线程池总共有 10 个线程 (server.tomcat.threads.max).您将在日志中看到线程名称,如下所示:

Regular requests on port 8080 will be served by threads from the standard thread pool, which will have a total of 10 threads (server.tomcat.threads.max). You will see the thread names in your log like this:

... nio-8080-exec-<number from 1 to 10>..

管理/健康检查线程将由来自不同线程池的线程提供服务,该线程池的总大小也为 10.您将在日志文件中看到这些线程,如下所示:

Management/health checks threads will be served by threads from a different thread pool, which will also have a total size of 10. You will see those threads in you log file like this:

... nio-8081-exec-<number from 1 to 10>..

注意: 这样做可能会解决您的健康检查失败导致 pod 重新启动的问题,但是它可能无法解决您在爆发时占用所有工作线程的根本原因的交通.也许您需要研究诸如速率限制之类的东西来处理这种情况,这样您的服务就不会获得超出其处理能力的流量.

NOTE: doing this will maybe solve your issue with failing health checks that cause the pods to be restarted, however it might not solve your root cause of all worker threads being occupied when there is a burst of traffic. Perhaps you need to look into something like rate limiting to deal with such scenario, so your service is not getting more traffic than it can handle.

这篇关于Spring boot:用于在管理端口上服务请求的线程池的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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