在 CentOS 上优化 WebLogic,一般从 操作系统层、JVM 层、WebLogic 配置层、网络与线程层 几个方面入手。下面给你一套比较实用、可落地的优化方案。
# 文件描述符
fs.file-max = 6815744
# TCP 连接优化
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 0
net.ipv4.tcp_fin_timeout = 30
net.ipv4.tcp_keepalive_time = 300
net.core.somaxconn = 65535
net.core.netdev_max_backlog = 65535
# 内存与交换
vm.swappiness = 10
执行:
sysctl -p
weblogic soft nofile 65536
weblogic hard nofile 65536
weblogic soft nproc 65536
weblogic hard nproc 65536
systemctl stop firewalld
systemctl disable firewalld
# 如非必要,关闭 SELinux
setenforce 0
export USER_MEM_ARGS="-Xms4g -Xmx4g -XX:MetaspaceSize=512m -XX:MaxMetaspaceSize=512m"
建议:
-Xms = -Xmx(避免动态扩容)JDK 8(推荐 G1)
-XX:+UseG1GC
-XX:MaxGCPauseMillis=200
-XX:+PrintGCDetails
-XX:+PrintGCDateStamps
-Xloggc:/logs/weblogic/gc.log
JDK 11+
-XX:+UseG1GC
Administration Console
-> Servers -> Configuration -> Threads
Initial Capacity = 20
Max Capacity = 100
Min Capacity = 20
Inactive Connection Timeout = 300
Test Connections On Reserve = true
/usr/java/bin/java ... -Dweblogic.NativeIOEnabled=true
提升 socket 性能。
Servers -> Protocols -> HTTP
-> Enable Keep Alive = true
Servers -> Configuration -> Tuning
-> Accept Backlog = 2048
WARNING 或 ERROR
避免 DEBUG
如果你能提供:
我可以给你更精准的调优参数模板。