Tomcat 8 - Serving Static content extremely slow...
Asked by B_ Normann P_ Nielsen:

After upgrading my Confluence to newest (and hence Tomcat 8), serving some static content became extremely poor in performance.

I have the AllowLinking=true, so some js scripts and css resources could be fetched from the filesystem. No problem until Tomcat 8, where the time from the server went to:

Screen Shot 2015-09-17 at 17.58.03.jpg

Uploading the files to Confluence and making a link to /download/xxxxxxx/filename.js solved the issue, and the time for the 2 files is roughly around 64ms per file. This is an acceptable solution, as migrations and stuff gets a bit simpler, but still... why the extreme poor performance. No changes to OS og Filesystem or similar, just the upgrade.....  
[](https://community.atlassian.com/t5/Confluence-questions/Tomcat-8-Serving-Static-content-extremely-slow/qaq-p/265520?attachment-id=3078){#link_1187ef2baff641}  
[](/tnckb94959/attachments/tnckb94959/confluence-questions/44812/1/Screen%20Shot%202015-09-17%20at%2017.58.03.jpg){#display_1187ef2baff641_0}


Answers:
author: chucktalk
body: Hi Normann,

I am not sure of your network setup, but you can add the following to your Connector parameter within server.xml:

*\<Connector port="8575" connectionTimeout="20000" redirectPort="8443"*   
*maxThreads="200" minSpareThreads="10" **compression="on"***   
***compressableMimeType="text/html,text/xml,text/plain,text/css,application/json,application/javascript,image/gif,image/jpg,image/png"***   
*protocol="org.apache.coyote.http11.Http11NioProtocol"*   
*enableLookups="false" acceptCount="10" debug="0" URIEncoding="UTF-8" /\>*

That should help with delivery of the static resources. In the alternative, you could use an Apache front-end to cache the static resources for delivery to end users as well.

Sincerely,

Chuck

comments: author: B_ Normann P_ Nielsen
body: Sounds interesting, and Apache has always been the frontend - but I dont want to "disconnect" resources to much from the Confluence Instance. I will look into the compression though....


author: Dmitry [Lucidchart]
body: I had to also add \`useSendfile="false"\` to the Connector element in order for the compression to work.


author: Remo Siegwart
body: We've experienced similar issues with custom and even Confluence supplied JS files: <https://jira.atlassian.com/browse/CONF-39298>In our case, it looks like only JS files are affected by this issue.


author: William Zanchet [Atlassian]
body: Hi Normann,  

If you upgraded Confluence out-of-the-box, it's more likely that you're with the default memory settings. Would you mind checking the following?  

To increase the JVM memory, here are the steps:  

Linux:  

# From \<confluence-install\>/bin (Stand-alone) or \<Tomcat-home\>/bin (EAR-WAR installation), open setenv.sh (you can create this file in the EAR/WAR version).  
# Find the section JAVA_OPTS="-Xms256m -Xmx512m -XX:MaxPermSize=256m ...  
# See Diagnosis above and enter the appropriate values. Xmx is maximum, Xms is minimum, and MaxPermSize is PermGen.  

Windows:  

# From \<confluence-install\>/bin (Stand-alone) or \<Tomcat-home\>/bin (EAR-WAR installation), open setenv.bat.  
# Find the section set JAVA_OPTS=%JAVA_OPTS% -Xms256m -Xmx512m -XX:MaxPermSize=256m  
# See Diagnosis above and enter the appropriate values. Xmx is maximum, Xms is minimum, and MaxPermSize is PermGen.  

Running Confluence as a Service:  

\* You can scroll down to Windows Service section: <https://confluence.atlassian.com/display/CONFKB/How+to+Fix+Out+of+Memory+Errors+by+Increasing+Available+Memory#HowtoFixOutofMemoryErrorsbyIncreasingAvailableMemory-SettingPropertiesforWindowsServicesviatheWindowsRegistry>\]  

<br />

For more information, you can refer to this documentation: :How to Fix Out of Memory Errors by Increasing Available Memory:  
<https://confluence.atlassian.com/display/CONFKB/How+to+Fix+Out+of+Memory+Errors+by+Increasing+Available+Memory#HowtoFixOutofMemoryErrorsbyIncreasingAvailableMemory-Step2:IncreaseAvailableMemory>\].  

<br />

Cheers,  
WZ

comments: author: B_ Normann P_ Nielsen
body: Current config (as before):-Djava.util.logging.config.file=/opt/confluence/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -XX:-UseAESIntrinsics -Djava.awt.headless=true -Xloggc:/opt/confluence/logs/gc-2015-09-17_18-42-22.log -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=2M -XX:-PrintGCDetails -XX:+PrintGCTimeStamps -XX:-PrintTenuringDistribution -Xms2048m -Xmx2048m -XX:MaxPermSize=1024m -XX:+UseG1GC -Djava.endorsed.dirs=/opt/confluence/endorsed -Dcatalina.base=/opt/confluence -Dcatalina.home=/opt/confluence -Djava.io.tmpdir=/opt/confluence/tempI always (after upgrade) - need to change settings in setenv.sh - And I can for sure set it higher, but this is a small website for my personal use only ....But thanx for the answer :-)


author: B_ Normann P_ Nielsen
body: Afterwards I have swiched from Apache2 to NGIX and killed a lot of old not used plugins to finetune.


Tags: confluence-administration