Using the NIO connector in Confluence to improve performance

Still need help?

The Atlassian Community is here for you.

Ask the community

Platform Notice: Server and Data Center Only - This article only applies to Atlassian products on the server and data center platforms.

Problem

Confluence will become unresponsive during periods of high load. Given a little time, the instance may recover naturally and become usable again without having to restart. Profiling tools will show that the majority of tomcat HTTP threads are busy and CPU usage will be high. Thread dumps will contain a lot of stack traces with the following:

apache.coyote.http11.InternalInputBuffer.parseRequestLine

Cause

By default Confluence uses the Coyote Connector, along with a 20 second timeout.

This is the default connector in Confluence 5.5.4 and all following versions:

<Connector port="8090" connectionTimeout="20000" redirectPort="8443"
	maxThreads="200" minSpareThreads="10"
    enableLookups="false" acceptCount="10" debug="0" URIEncoding="UTF-8" />

This is the default connector from before Confluence 5.5.4:

<Connector className="org.apache.coyote.tomcat4.CoyoteConnector" port="8090" minProcessors="5"
	maxProcessors="75"
	enableLookups="false" redirectPort="8443" acceptCount="10" debug="0" connectionTimeout="20000"
	useURIValidationHack="false" URIEncoding="UTF-8"/>

When a request is made to the server, Confluence will provide that request a thread, meaning there will be one thread consumed per concurrent connection. If the connection is used just enough to not trigger the timeout (20 seconds by default), the thread will be continually held by this connection and wasted.

Under high load this can result in connections that are consuming server resources and preventing them from being used by other HTTP threads for long periods, even if they are doing very little.

Workaround

  • The following workaround should be thoroughly tested in a test instance before being applied to a production instance.
  • Please be aware that this material is provided for your information only and that you use it at your own risk.
  • You should only use this workaround if you're running Java version 7 Update 25 or higher. Confluence 4.2 is the first version of Confluence that supports Java version 7.
  • Shut down Confluence
  • Locate server.xml, in your <installation_directory>/conf/ folder; and open it in a text editor
  • Locate your connector - it will be similar to the connector shown above

    In Confluence 5.5.4 and beyond, Tomcat will be configured to use the default http11protocol connector. However, you can add protocol="org.apache.coyote.http11.Http11NioProtocol" to the connector

    Here's the default connector, using the NIO Connector - notice the protocol attribute:

    <Connector port="8090" connectionTimeout="20000" redirectPort="8443"
    	maxThreads="200" minSpareThreads="10"
        enableLookups="false" acceptCount="10" debug="0" URIEncoding="UTF-8"
        protocol="org.apache.coyote.http11.Http11NioProtocol" />
  • Save the file and restart Confluence

The NIO Connector is a non-blocking type of connector. It will poll connections to see which ones are actually being used (as opposed to waiting for them to timeout); and should result in the available threads being used more efficiently.

For more advanced tomcat configuration options please refer to Tomcat Official Documentation.

Last modified on Feb 26, 2016

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.