Spring Boot - 限制创建的连接数 [英] Spring Boot - Limit on number of connections created

查看:1633
本文介绍了Spring Boot - 限制创建的连接数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Spring Boot开发了一个微服务。我通过存根后端调用来测试服务的性能。当我查看线程计数时,我发现在任何时间点创建到服务的最大线程数是20,即使调用的数量要高得多。对于可以对使用Spring Boot开发的微服务进行的调用次数是否有任何限制。请您指导一下我需要遵循哪些步骤来解决/增加服务接受的连接数?

I developed a microservice using Spring Boot. I was performance testing the service by stubbing the backend calls. When I looked at the thread count , I see that the maximum number of threads that created to the service is 20 at any point in time even though the number of calls made is much higher. Are there any limitations with respect to number of calls that can be made to a microservice developed using Spring Boot. Please can you guide in what steps I need to follow to troubleshoot / increase the number of connections accepted by the service?

推荐答案

这个设置源自嵌入式容器(tomcat,jetty ...)。

This setting is derived from the embedded container (tomcat, jetty...).

Tomcat的线程数

您可以在application.properties中指定此属性

You may specify this property in your application.properties

server.tomcat.max-threads=400

你说你计算了20个线程,但根据这个其他stackoverflow问题/答案,默认的线程数应该是200与tomcat,自server.tomcat。 max-threads的默认值为0.请参阅 tomcat的文档

You say you counted 20 threads, however according to this other stackoverflow question/answer, the default number of thread should be 200 with tomcat, since server.tomcat.max-threads's default value is 0. See tomcat's documentation:


请求处理的最大数量g由此Connector创建的线程,因此确定可以处理的最大并发请求数。如果未指定,则此属性设置为200.如果执行程序与此连接器关联,则忽略此属性,因为连接器将使用执行程序而不是内部线程池执行任务。

The maximum number of request processing threads to be created by this Connector, which therefore determines the maximum number of simultaneous requests that can be handled. If not specified, this attribute is set to 200. If an executor is associated with this connector, this attribute is ignored as the connector will execute tasks using the executor rather than an internal thread pool.

此外,该属性:


  • 下载 server.undertow.worker-threads

jetty server.jetty.acceptors

你会发现 Spring的文档

这篇关于Spring Boot - 限制创建的连接数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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