Solved 503 Timeout or Service Temporarily Unavailable

Hello everyone, my Lucee installation runs on a Plesk server with AlmaLinux.
Occasionally, during complex and long-running processes involving thousands of records (even more than 10k), my applications would throw 503 Timeout or Service Temporarily Unavailable errors.

Finally, I found a configuration that seems to have resolved the issue.

Obviously, many of the suggestions come directly from ChatGPT.

Do you have any other recommendations to improve Lucee’s performance?
This could serve as a mini guide.
Thank You.

On Plesk
Additional Apache directives:

ProxyTimeout 600
Timeout 600

ModPagespeed off

Additional Nginx directives:

proxy_connect_timeout 600s;
proxy_send_timeout 600s;
proxy_read_timeout 600s;
send_timeout 600s;
proxy_buffering off;

On the server::

/opt/lucee/tomcat/conf/server.xml

Modify the connector:
OLD

NEW

nano /opt/lucee/tomcat/bin/setenv.sh

#!/bin/bash

Memory

export JAVA_OPTS=“-Xms2048m -Xmx4096m”

Metaspace (classi)

export JAVA_OPTS=“$JAVA_OPTS -XX:MetaspaceSize=512m -XX:MaxMetaspaceSize=2048m”

TLS

export JAVA_OPTS=“$JAVA_OPTS -Dhttps.protocols=TLSv1.2 -Djdk.tls.client.protocols=TLSv1.2”

Garbage Collector (G1GC)

export JAVA_OPTS=“$JAVA_OPTS -XX:+UseG1GC -XX:MaxGCPauseMillis=200 -XX:InitiatingHeapOccupancyPercent=35 -XX:+ParallelRefProcEnabled”

General optimizations

export JAVA_OPTS=“$JAVA_OPTS -XX:+HeapDumpOnOutOfMemoryError -XX:+ExitOnOutOfMemoryError -Djava.awt.headless=true -Dfile.encoding=UTF-8”

Log GC (optional, useful for monitoring) – I did not include it

export JAVA_OPTS=“$JAVA_OPTS -Xlog:gc*:file=/opt/lucee/tomcat/logs/gc.log:time,uptime,level,tags -XX:+PrintGCDateStamps”

Lucee Log Rotation
New file:

nano /etc/logrotate.d/lucee

content:

/opt/lucee/tomcat/logs/catalina.out {
daily
rotate 14
compress
missingok
copytruncate
}