Need ability to configure Tomcat KeepAliveTimeout

Our Setup:
Sonarqube 9.3.0.51899 (Enterprise)
Google HTTP(S) Load Balancer

Our Issue:
We are simply trying to serve Sonarqube from our GCP LoadBalancer. Analysis fails intermittently with LB timeout, as I’ve posted in more detail here: Analysis fails during plugin download

I found the following in GCP LoadBalancer documentation:

HTTP keepalive timeout , whose value is fixed at 10 minutes (600 seconds). This value is not configurable by modifying your backend service. You must configure the web server software used by your backends so that its keepalive timeout is longer than 600 seconds to prevent connections from being closed prematurely by the backend

According to the Tomcat metrics exposed by Sonarqube, the keepalive timeout is configured as 60 seconds

➜  curl "http://localhost:8000" | grep -i keepalivetimeout

Tomcat_ProtocolHandler_keepAliveTimeout Introspected attribute keepAliveTimeout (Tomcat<type=ProtocolHandler, port=9000, address="0.0.0.0"><>keepAliveTimeout)
# TYPE Tomcat_ProtocolHandler_keepAliveTimeout untyped
Tomcat_ProtocolHandler_keepAliveTimeout{port="9000",address="\"0.0.0.0\"",} 60000.0
# HELP Tomcat_Connector_keepAliveTimeout The number of milliseconds Tomcat will wait for a subsequent request before closing the connection (Tomcat<type=Connector, port=9000, address="0.0.0.0"><>keepAliveTimeout)
# TYPE Tomcat_Connector_keepAliveTimeout untyped
Tomcat_Connector_keepAliveTimeout{port="9000",address="\"0.0.0.0\"",} 60000.0
# HELP Tomcat_ThreadPool_keepAliveTimeout null (Tomcat<type=ThreadPool, name="http-nio-0.0.0.0-9000"><>keepAliveTimeout)      
# TYPE Tomcat_ThreadPool_keepAliveTimeout untyped
Tomcat_ThreadPool_keepAliveTimeout{name="\"http-nio-0.0.0.0-9000\"",} 60000.0

Our Ask:
We need the ability to increase the keepalivetimeout to comply with GCP load balancers.

This is most likely the root cause for several issues on this forum regarding issues with Loadbalancers in front of Sonarqube.

Opened feat: support configuration of the tomcat keepAliveTimeout by jasondamour · Pull Request #3290 · SonarSource/sonarqube · GitHub

The above PR has been approved. The solution proposed by @jasondamour will be included in SonarQube 9.4.

The default timeout has not changed, a user will need to explicitly set it in the config by setting sonar.web.http.keepAliveTimeout.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.