Skip to content

Instantly share code, notes, and snippets.

@jamiejackson
Created July 21, 2023 18:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamiejackson/0e7f4eb399b161e610c1392c5d657d0e to your computer and use it in GitHub Desktop.
Save jamiejackson/0e7f4eb399b161e610c1392c5d657d0e to your computer and use it in GitHub Desktop.

Timeouts

Overview

This will serve to document various timeouts, what they're used for, and project-specific decisions as to their use/values.

Timeout Layers

In order to manage long running processes gracefully, we want to control when a request will be killed in different scenarios. The following table documents the different layers of the application stack and their associated timeout values.

Step Technology Timeout Notes
1 Lucee Application 80s
2 Tomcat server 85s * does not appear to be active; seems to be infinite
3 Fusion Reactor 90s
4 Apache Server 145s
5 Load Balancer 150s * also applies to local nginx proxy
6 CloudFront 60s "Origin Response Timeout" (a.k.a. origin_read_timeout ). Normally, we'd make this a little bigger than its upstream's timeout but AWS has this capped at 60s. We can request an increase through support if we need it.

JVM

Networking Timeouts

(These are being set in lucee/tomcat/bin/setenv.sh.)

Property (-D...) Description Default HUDX (ms) HUDX Justification Exception Message (Lucee)
sun.net.client.defaultConnectTimeout When a connection is made by an applet to a server and the server does not respond properly, the applet might seem to hang. The delay might also cause the browser to hang. The apparent hang occurs because there is no network connection timeout. To avoid this problem, the Java Plug-in has added a default value to the network timeout of 2 minutes for all HTTP connections. You can override the default by setting this property. (ref) The default value set by the protocol handlers is -1, which means that no timeout is set. 10000 Establishment of a connection should be very quick, and 10s is liberal. Haven't tested.
sun.net.client.defaultReadTimeout Specifies the default value for the read timeout for the protocol handlers used by the java.net.URLConnection class when reading from an input stream when a connection is established to a resource. (ref) The default value set by the protocol handlers is -1, which means that no timeout is set. 180000 HTTPClient calls (e.g., web service calls), etc., should have a finite limit. 3m is liberal, but we may have to increase this if we have legitimately long-running outgoing requests. Haven't tested.

Solr

This is an example of an implementation which sets its own timeouts:

ICFCFSolrLib:

	public function init() {
		param name="arguments.logFile" default=listLast(arguments.path, "/") & "Solr"; 
		return super.init(
			argumentCollection = arguments,
			soTimeout = 5000,
			connectionTimeout = 2000,
			logFile = logFile
		);
	}

In this case, the soTimeout (I think) corresponds to the defaultReadtimout set in JVM options, and the former overrides the latter. Similarly, connectionTimeout overrides defaultConnectionTiomeut from the JVM options.

Database

Client-Side

From highest to lowest level:

(Reference: http://www.cubrid.org/blog/dev-platform/understanding-jdbc-internals-and-timeout-configuration/ )

  • Connection Pool (a separate beast from the following)

  • Transaction

  • Statement

  • JDBC Driver Socket

Transaction

(As far as I know, this means) groups of queries run in a single SQL TRANSACTION. I'm not sure we have access to this timeout in CFML, as we would in, say Spring:

<!-- NB: This is not CFML -->
<tx:attributes>
	<tx:method name="" timeout="3"/>
</tx:attributes>

Statement

This is set in <cfquery timeout="value_in_ms">. (Is there a more global timeout somewhere?)

  • This should be set lower than the JDBC driver socket timeout value (since socket timouts shouldn't be used to limit the statement execution time).

(MySQL/MariaDB) JDBC Driver Socket Timeouts

These are the lowest-level of the client-side timeouts.

Notes:

  • This should be set higher than the statement timeout value (since socket timouts shouldn't be used to limit the statement execution time).
Property Description Default (ms) HUDX (ms) HUDX Justification Exception Message (Lucee)
connectTimeout Timeout for initial socket connection, with 0 meaning no timeout. 0 10000 Establishment of a connection should be very quick, and 10s is liberal. Could not connect to address=(host=localhost)(port=3306)(type=master) : null
socketTimeout Timeout on network socket operations (e.g., waiting for query response), with 0 meaning no timeout. 0 180000 Queries longer than 1.5m should be considered "runaway". Connection timed out

References:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment