Spring-boot tomcat is able to offer only lesser than 10,000 connections?

断了今生、忘了曾经 提交于 2019-12-21 04:21:31

问题


I am testing the server with spring-boot. However, I got some problems during doing test.

my test is How many memories server use with increasing the web socket sessions(the number of client).

1,000 clients(lesser than 9000 sessions) has no issues with doing the test. but, When I tried to test 10k connections, server made connections almost until 10,000.(sometimes creating sessions until 9990, sometimes 9988, 9996 like this, not the specific limit the number of socket) after that, it just stopped creating sessions, no errors just not responding.

If some clients get timeout and release the connection, other clients which were waiting to connect are able to get connections.

'environment' tomcat : 8.0.36 spring-boot : 1.3.3 java : 1.8

for solutions, I tried

  1. increasing heap size.

    • I increase jvm heap memory by 5GB. but heap memories which are used for connections are only 2GB. So, I think that it is not related to JVM memory.
  2. I set server.tomcat.max-thread = 20000 in application.porperties.

    • but it was failed, no difference before.

I am really curious about this issue. If you guys knows this problem and have ideas, let me know the reason. Thanks.


回答1:


Tomcat - maxThreads vs maxConnections

Try to set maxConnections property to be more than 10000.

From the doc:

The maximum number of connections that the server will accept and process at any given time. When this number has been reached, the server will accept, but not process, one further connection. This additional connection be blocked until the number of connections being processed falls below maxConnections at which point the server will start accepting and processing new connections again. Note that once the limit has been reached, the operating system may still accept connections based on the acceptCount setting. The default value varies by connector type. For BIO the default is the value of maxThreads unless an Executor is used in which case the default will be the value of maxThreads from the executor. For NIO the default is 10000. For APR/native, the default is 8192.

Note that for APR/native on Windows, the configured value will be reduced to the highest multiple of 1024 that is less than or equal to maxConnections. This is done for performance reasons. If set to a value of -1, the maxConnections feature is disabled and connections are not counted.




回答2:


There is a properties for spring boot, tomcat max-connection, which needs to be set in application.properties file

server.tomcat.max-connections= # Maximum number of connections that the server will accept and process at any given time.


来源:https://stackoverflow.com/questions/42219637/spring-boot-tomcat-is-able-to-offer-only-lesser-than-10-000-connections

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!