I am running multiple Tomcat instances for confluence, and faced that confluence page loading takes too long. In addition, my server suddenly faced huge amount of CPU consumption including memory.


I just checked server logs under <confluence_home>/logs, and found gc(garbage collection) is too frequently happening like below:

2019-10-03T08:15:03.247+0900: 0.508: [GC pause (G1 Evacuation Pause) (young) 51M->8753K(1024M), 0.0080534 secs]
2019-10-03T08:15:03.262+0900: 0.523: [GC pause (G1 Evacuation Pause) (young) 56M->11M(1024M), 0.0053004 secs]
2019-10-03T08:15:03.294+0900: 0.556: [GC pause (G1 Evacuation Pause) (young) 102M->9339K(1024M), 0.0063752 secs]
2019-10-03T08:15:03.711+0900: 0.973: [GC pause (G1 Evacuation Pause) (young) 238M->33M(1024M), 0.0097486 secs]
2019-10-03T08:15:04.146+0900: 1.408: [GC pause (Metadata GC Threshold) (young) (initial-mark) 375M->35M(1024M), 0.0134586 secs]
2019-10-03T08:15:04.159+0900: 1.421: [GC concurrent-root-region-scan-start]
2019-10-03T08:15:04.165+0900: 1.426: [GC concurrent-root-region-scan-end, 0.0051882 secs]
2019-10-03T08:15:04.165+0900: 1.426: [GC concurrent-mark-start]
2019-10-03T08:15:04.174+0900: 1.436: [GC concurrent-mark-end, 0.0092882 secs]
2019-10-03T08:15:04.174+0900: 1.436: [GC remark, 0.0079985 secs]
2019-10-03T08:15:04.182+0900: 1.444: [GC cleanup 43M->42M(1024M), 0.0012105 secs]
2019-10-03T08:15:04.184+0900: 1.445: [GC concurrent-cleanup-start]
2019-10-03T08:15:04.184+0900: 1.445: [GC concurrent-cleanup-end, 0.0000095 secs]
2019-10-03T08:15:05.191+0900: 2.453: [GC pause (G1 Evacuation Pause) (young) 620M->32M(1024M), 0.0208483 secs]
2019-10-03T08:15:05.232+0900: 2.494: [GC pause (Metadata GC Threshold) (young) (initial-mark) 48M->21M(1024M), 0.0099396 secs]
2019-10-03T08:15:05.242+0900: 2.504: [GC concurrent-root-region-scan-start]
2019-10-03T08:15:05.249+0900: 2.511: [GC concurrent-root-region-scan-end, 0.0065674 secs]
2019-10-03T08:15:05.249+0900: 2.511: [GC concurrent-mark-start]
2019-10-03T08:15:05.258+0900: 2.520: [GC concurrent-mark-end, 0.0091580 secs]
2019-10-03T08:15:05.258+0900: 2.520: [GC remark, 0.0050039 secs]
2019-10-03T08:15:05.264+0900: 2.525: [GC cleanup 33M->33M(1024M), 0.0006691 secs]
2019-10-03T08:15:06.031+0900: 3.293: [GC pause (G1 Evacuation Pause) (young) 620M->29M(1024M), 0.0132937 secs]
2019-10-03T08:15:07.009+0900: 4.271: [GC pause (G1 Evacuation Pause) (young) 619M->36M(1024M), 0.0165249 secs]
2019-10-03T08:15:07.371+0900: 4.633: [GC pause (G1 Evacuation Pause) (young) 619M->38M(1024M), 0.0165669 secs]
2019-10-03T08:15:07.848+0900: 5.110: [GC pause (G1 Evacuation Pause) (young) 620M->38M(1024M), 0.0168380 secs]
2019-10-03T08:15:08.347+0900: 5.609: [GC pause (G1 Evacuation Pause) (young) 619M->38M(1024M), 0.0194591 secs]
2019-10-03T08:15:09.116+0900: 6.378: [GC pause (Metadata GC Threshold) (young) (initial-mark) 445M->41M(1024M), 0.0233125 secs]
2019-10-03T08:15:09.139+0900: 6.401: [GC concurrent-root-region-scan-start]
2019-10-03T08:15:09.154+0900: 6.416: [GC concurrent-root-region-scan-end, 0.0149217 secs]
2019-10-03T08:15:09.154+0900: 6.416: [GC concurrent-mark-start]
2019-10-03T08:15:09.164+0900: 6.425: [GC concurrent-mark-end, 0.0093707 secs]
2019-10-03T08:15:09.164+0900: 6.426: [GC remark, 0.0147820 secs]
2019-10-03T08:15:09.179+0900: 6.441: [GC cleanup 46M->46M(1024M), 0.0016675 secs]
2019-10-03T08:15:09.922+0900: 7.184: [GC pause (G1 Evacuation Pause) (young) 620M->46M(1024M), 0.0309030 secs]
2019-10-03T08:15:10.683+0900: 7.944: [GC pause (G1 Evacuation Pause) (young) 620M->47M(1024M), 0.0250404 secs]
2019-10-03T08:15:11.626+0900: 8.888: [GC pause (G1 Evacuation Pause) (young) 619M->55M(1024M), 0.0308118 secs]
2019-10-03T08:15:12.369+0900: 9.631: [GC pause (G1 Evacuation Pause) (young) 620M->57M(1024M), 0.0378077 secs]
2019-10-03T08:15:13.106+0900: 10.368: [GC pause (G1 Evacuation Pause) (young) 625M->67M(1024M), 0.0291737 secs]
2019-10-03T08:15:14.045+0900: 11.307: [GC pause (G1 Evacuation Pause) (young) 635M->79M(1024M), 0.0345576 secs]
2019-10-03T08:15:14.766+0900: 12.027: [GC pause (G1 Evacuation Pause) (young) 640M->83M(1024M), 0.0269449 secs]
2019-10-03T08:15:15.368+0900: 12.630: [GC pause (G1 Evacuation Pause) (young) 651M->89M(1024M), 0.0275620 secs]
2019-10-03T08:15:16.146+0900: 13.408: [GC pause (G1 Evacuation Pause) (young) 655M->106M(1024M), 0.0350529 secs]
2019-10-03T08:15:17.139+0900: 14.401: [GC pause (G1 Evacuation Pause) (young) 664M->113M(1024M), 0.0373316 secs]
2019-10-03T08:15:17.823+0900: 15.084: [GC pause (G1 Evacuation Pause) (young) 680M->120M(1024M), 0.0372325 secs]
2019-10-03T08:15:18.748+0900: 16.010: [GC pause (Metadata GC Threshold) (young) (initial-mark) 382M->119M(1024M), 0.0414172 secs]
2019-10-03T08:15:18.790+0900: 16.051: [GC concurrent-root-region-scan-start]
2019-10-03T08:15:18.819+0900: 16.080: [GC concurrent-root-region-scan-end, 0.0290015 secs]
2019-10-03T08:15:18.819+0900: 16.080: [GC concurrent-mark-start]
2019-10-03T08:15:18.877+0900: 16.139: [GC concurrent-mark-end, 0.0584421 secs]
2019-10-03T08:15:18.877+0900: 16.139: [GC remark, 0.0120079 secs]
2019-10-03T08:15:18.890+0900: 16.151: [GC cleanup 128M->128M(1024M), 0.0012959 secs]
2019-10-03T08:15:20.473+0900: 17.735: [GC pause (G1 Evacuation Pause) (young) (initial-mark) 684M->129M(1024M), 0.0390524 secs]
2019-10-03T08:15:20.512+0900: 17.774: [GC concurrent-root-region-scan-start]
2019-10-03T08:15:20.541+0900: 17.803: [GC concurrent-root-region-scan-end, 0.0284405 secs]
2019-10-03T08:15:20.541+0900: 17.803: [GC concurrent-mark-start]
2019-10-03T08:15:20.634+0900: 17.896: [GC concurrent-mark-end, 0.0931467 secs]
2019-10-03T08:15:20.634+0900: 17.896: [GC remark, 0.0115694 secs]
2019-10-03T08:15:20.646+0900: 17.908: [GC cleanup 193M->193M(1024M), 0.0009227 secs]
2019-10-03T08:15:21.579+0900: 18.841: [GC pause (G1 Evacuation Pause) (young) 693M->135M(1024M), 0.0319757 secs]
2019-10-03T08:15:22.602+0900: 19.864: [GC pause (G1 Evacuation Pause) (young) 700M->150M(1024M), 0.0378344 secs]

If it is, it looks like your system has some conflict in communication ports. You should take a look following two items. 


Check instance ports at <confluence home>/conf/server.xml

You should use unique server port number. On below example, my port number is 28002.

<Server port="28002" shutdown="SHUTDOWN" debug="0">
    <Service name="Tomcat-Standalone">
        <!--
         ==============================================================================================================
         DEFAULT - Direct connector with no proxy, for unproxied HTTP access to Confluence.

         If using a http/https proxy, comment out this connector.
         ==============================================================================================================
        -->
.
.
.


You also need to check your server instance port number. On below case, the port number I use is 28190.

<Service name="Tomcat-Standalone">
...
    <Connector port="28190" connectionTimeout="20000" redirectPort="8443"
        maxThreads="48" minSpareThreads="10"
        enableLookups="false" acceptCount="10" debug="0" URIEncoding="UTF-8"
        protocol="org.apache.coyote.http11.Http11NioProtocol"/>
...


Synchrony port at <confluence home>/bin/setenv.sh

You should check if your collaborative editor port does not make any conflict with other application including confluence instances. If you run more than one confluence on your server, you should change the port number.

The action you should do is simple - just adding one more a line below Dsynchrony.enable.xhr.fallback. Note you should use your own unique port for collaborative editor. If you have three different confluence instances, you should have three different ports.

CATALINA_OPTS="-Dsynchrony.port=28191 ${CATALINA_OPTS}"

For your information, the default port number is 8091. If you have more than two confluence instances, you should have different port numbers to avoid conflicts.

Below is the actual example I made

.
.
.
.
# Set the JVM arguments used to start Confluence. For a description of the options, see
# http://www.oracle.com/technetwork/java/javase/tech/vmoptions-jsp-140102.html
CATALINA_OPTS="-XX:-PrintGCDetails -XX:+PrintGCDateStamps -XX:-PrintTenuringDistribution ${CATALINA_OPTS}"
CATALINA_OPTS="-Xloggc:$LOGBASEABS/logs/gc-`date +%F_%H-%M-%S`.log -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=2M ${CATALINA_OPTS}"
CATALINA_OPTS="-XX:G1ReservePercent=20 ${CATALINA_OPTS}"
CATALINA_OPTS="-Djava.awt.headless=true ${CATALINA_OPTS}"
CATALINA_OPTS="-Datlassian.plugins.enable.wait=300 ${CATALINA_OPTS}"
CATALINA_OPTS="-Xms1024m -Xmx1024m -XX:+UseG1GC ${CATALINA_OPTS}"
CATALINA_OPTS="-Dsynchrony.enable.xhr.fallback=true ${CATALINA_OPTS}"
CATALINA_OPTS="-Dsynchrony.port=28191 ${CATALINA_OPTS}"
CATALINA_OPTS="-Dorg.apache.tomcat.websocket.DEFAULT_BUFFER_SIZE=32768 ${CATALINA_OPTS}"
CATALINA_OPTS="-Djava.locale.providers=COMPAT,SPI ${CATALINA_OPTS}"
CATALINA_OPTS="${START_CONFLUENCE_JAVA_OPTS} ${CATALINA_OPTS}"
CATALINA_OPTS="-Dconfluence.context.path=${CONFLUENCE_CONTEXT_PATH} ${CATALINA_OPTS}"
CATALINA_OPTS="-XX:ReservedCodeCacheSize=256m -XX:+UseCodeCacheFlushing ${CATALINA_OPTS}"
.
.
.