在 CentOS 上优化 WebLogic,通常从 操作系统层、JVM 层、WebLogic 配置层、应用层 四个维度来做。下面给你一套比较实用、可落地的优化方案。
# TCP 连接优化
net.core.somaxconn = 65535
net.core.netdev_max_backlog = 65535
net.ipv4.tcp_max_syn_backlog = 8192
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_fin_timeout = 30
# 文件句柄
fs.file-max = 1000000
执行:
sysctl -p
weblogic soft nofile 65535
weblogic hard nofile 65535
weblogic soft nproc 65535
weblogic hard nproc 65535
systemctl stop firewalld
systemctl disable firewalld
(生产环境建议用 iptables 或安全组替代)
示例(8C16G 服务器):
-Xms4g
-Xmx4g
-XX:MetaspaceSize=512m
-XX:MaxMetaspaceSize=512m
-XX:+UseG1GC
-XX:MaxGCPauseMillis=200
-XX:+HeapDumpOnOutOfMemoryError
-XX:HeapDumpPath=/opt/dump
⚠ 注意:
- Xms = Xmx(避免动态扩容)
- 保留系统内存,不要全给 JVM
Administration Console
-> Servers -> Configuration -> Threads
建议:
Initial Capacity = 20
Max Capacity = 100
Min Capacity = 20
Inactive Connection Timeout = 300
Test Connections On Reserve = true
/opt/weblogic/user_projects/domains/base_domain/bin/setDomainEnv.sh
确保:
-Dweblogic.nativeio.enabled=true
Production Mode = true
关闭:
<filter>
<filter-name>gzip</filter-name>
<filter-class>weblogic.servlet.gzip.GzipFilter</filter-class>
</filter>
# CPU
top -Hp <pid>
# 线程栈
jstack <pid> > thread.txt
# 内存
jmap -heap <pid>
jstat -gcutil <pid> 1000
| 场景 | 配置 |
|---|---|
| 4C8G | Xmx4g,线程100 |
| 8C16G | Xmx8g,线程200 |
| 16C32G | Xmx16g,线程400 |
如果你能告诉我:
我可以给你一套 针对性配置模板。