Debian上WebLogic集群的负载均衡策略
一、策略总览与适用场景
| 策略 | 适用对象 | 实现位置 | 关键说明 |
|---|---|---|---|
| 轮询 Round-Robin | Servlets/JSPs、EJBs、RMI | 外部 HTTP LB(如 Nginx/HAProxy)、WebLogic HttpClusterServlet 插件、内置对象存根 | 默认策略,简单可预测;慢节点可能引发“convoying”(请求同步排队) |
| 最少连接 Least Connections | HTTP 流量 | Nginx/HAProxy | 将请求发给当前连接数最少的实例,适合长连接/处理能力不均场景 |
| 权重 Weight-Based | EJBs、RMI | WebLogic 集群配置 | 为实例设置 1–100 权重,适配异构硬件;对 RMI/IIOP 不支持 |
| 随机 Random | EJBs、RMI | WebLogic 集群配置 | 仅建议同构集群;小样本下可能不均衡 |
| 会话保持(IP Hash / Cookie 持久化) | HTTP 会话 | Nginx ip_hash、外部 LB 的 cookie 持久化 | 同一客户端固定到同一实例;注意跨节点会话复制或粘性配置 |
| 服务器亲和(Server Affinity) | RMI/EJB/JMS | WebLogic 内置 | 外部客户端优先复用既有连接;与 round-robin/weight/random 组合使用 |
| 基于参数的路由 | EJBs、RMI | WebLogic 配置 | 按方法参数定制路由,满足特定业务分流需求 |
二、外部负载均衡器策略与配置要点(Nginx/HAProxy)
server weblogic1.example.com max_fails=3 fail_timeout=30s;upstream weblogic_cluster {
least_conn;
server weblogic1.example.com:7001;
server weblogic2.example.com:7001;
server weblogic3.example.com:7001 max_fails=3 fail_timeout=30s;
}
server {
listen 80;
location / {
proxy_pass http://weblogic_cluster;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
upstream weblogic_cluster {
server weblogic1.example.com:7001 weight=3;
server weblogic2.example.com:7001 weight=2;
server weblogic3.example.com:7001 weight=1;
}
upstream weblogic_cluster {
ip_hash;
server weblogic1.example.com:7001;
server weblogic2.example.com:7001;
}
sudo nginx -tsudo systemctl reload nginx三、WebLogic内置对象负载均衡策略(EJBs与RMI)
四、会话保持与故障转移建议
五、快速选型建议