我使用 Spring Boot 开发了一个微服务。我通过存根后端调用来测试服务的性能。当我查看线程数时,我发现在任何时间点为服务创建的最大线程数都是 20,即使调用的次数要高得多。对于可以对使用 Spring Boot 开发的微服务进行的调用次数是否有任何限制。请您指导我需要遵循哪些步骤来排除故障/增加服务接受的连接数?
原文由 Punter Vicky 发布,翻译遵循 CC BY-SA 4.0 许可协议
我使用 Spring Boot 开发了一个微服务。我通过存根后端调用来测试服务的性能。当我查看线程数时,我发现在任何时间点为服务创建的最大线程数都是 20,即使调用的次数要高得多。对于可以对使用 Spring Boot 开发的微服务进行的调用次数是否有任何限制。请您指导我需要遵循哪些步骤来排除故障/增加服务接受的连接数?
原文由 Punter Vicky 发布,翻译遵循 CC BY-SA 4.0 许可协议
也许,你可以看看 springboot的配置
server.tomcat.accept-count=100 # Maximum queue length for incoming connection requests when all possible request processing threads are in use.
server.tomcat.additional-tld-skip-patterns= # Comma-separated list of additional patterns that match jars to ignore for TLD scanning.
server.tomcat.background-processor-delay=10s # Delay between the invocation of backgroundProcess methods. If a duration suffix is not specified, seconds will be used.
server.tomcat.basedir= # Tomcat base directory. If not specified, a temporary directory is used.
server.tomcat.max-connections=10000 # Maximum number of connections that the server accepts and processes at any given time.
server.tomcat.max-http-header-size=0 # Maximum size in bytes of the HTTP message header.
server.tomcat.max-http-post-size=2097152 # Maximum size in bytes of the HTTP post content.
server.tomcat.max-threads=200 # Maximum amount of worker threads.
server.tomcat.min-spare-threads=10 # Minimum amount of worker threads.
server.tomcat.port-header=X-Forwarded-Port # Name of the HTTP header used to override the original port value.
server.tomcat.protocol-header= # Header that holds the incoming protocol, usually named "X-Forwarded-Proto".
server.tomcat.protocol-header-https-value=https # Value of the protocol header indicating whether the incoming request uses SSL.
server.tomcat.redirect-context-root=true # Whether requests to the context root should be redirected by appending a / to the path.
server.tomcat.remote-ip-header= # Name of the HTTP header from which the remote IP is extracted. For instance, `X-FORWARDED-FOR`.
server.tomcat.resource.cache-ttl= # Time-to-live of the static resource cache.
server.tomcat.uri-encoding=UTF-8 # Character encoding to use to decode the URI.
server.tomcat.use-relative-redirects= # Whether HTTP 1.1 and later location headers generated by a call to sendRedirect will use relative or absolute redirects.
原文由 Bruce 发布,翻译遵循 CC BY-SA 4.0 许可协议
15 回答8.4k 阅读
8 回答6.2k 阅读
1 回答4.1k 阅读✓ 已解决
3 回答2.2k 阅读✓ 已解决
2 回答3.1k 阅读
2 回答3.8k 阅读
3 回答1.7k 阅读✓ 已解决
此设置源自嵌入式容器(tomcat、jetty…)。
Tomcat的线程数
您可以在 application.properties 中指定此属性
您说您计算了 20 个线程,但是根据这个 其他 stackoverflow 问题/答案,tomcat 的默认线程数应该是 200,因为 server.tomcat.max-threads 的默认值为 0。请参阅 tomcat 的文档:
此外,该物业:
暗流:
server.undertow.worker-threads
码头:
server.jetty.acceptors
您将在 Spring 的文档 中找到属性列表