如何使用 HAProxy 进行粘性负载平衡并将会话传输到新服务器

发布于 2024-08-06 08:21:53 字数 1004 浏览 2 评论 0原文

我正在使用 appsession 配置元素来进行粘性会话。我有 5 个 weblogic 实例,其中 3 个处于活动状态并正在提供负载,当负载增加时,我会启动另外 2 个实例。现在,HAProxy 将它们标记为“Helthy”,但不会向其传输任何流量,因为它具有粘性。

如何将现有会话转移到新的 weblogic 服务器。我使用 Terracotta 进行会话集群,因此哪个服务器正在处理请求并不重要。以下是我的 HAProxy 配置。

# this config needs haproxy-1.1.28 or haproxy-1.2.1

global
      log 127.0.0.1   local0
      maxconn 1024
      daemon
     # debug
      #quiet

defaults
      log     global
      mode    http
      option  httplog
      option  httpchk
      option  httpclose
      retries 3
      option redispatch
      contimeout      5000
      clitimeout      50000
      srvtimeout      50000
      stats uri /admin?stats
      stats refresh 5s

listen  terracotta 0.0.0.0:10001
#     balance url_param JSESSIONID
      balance roundrobin
      option httpchk OPTIONS /Townsend
      server  L1_1 10.211.55.1:7003  check
      server  L1_2 10.211.55.2:7004  check
   server  L1_3 10.211.55.3:7004  check
      appsession JSESSIONID len 52 timeout 3h

I am using appsession config element for sticky session. I have 5 weblogic instances 3 of them are active and serving load now when load increases i start additional 2 instances. Now HAProxy marks them "Helthy" but does not transfer any traffic to it because it sticky.

How do I transfer existing sessions to new weblogic servers. I am using Terracotta for session clustering so it does not matter which server is serving the request. Below is my config for HAProxy.

# this config needs haproxy-1.1.28 or haproxy-1.2.1

global
      log 127.0.0.1   local0
      maxconn 1024
      daemon
     # debug
      #quiet

defaults
      log     global
      mode    http
      option  httplog
      option  httpchk
      option  httpclose
      retries 3
      option redispatch
      contimeout      5000
      clitimeout      50000
      srvtimeout      50000
      stats uri /admin?stats
      stats refresh 5s

listen  terracotta 0.0.0.0:10001
#     balance url_param JSESSIONID
      balance roundrobin
      option httpchk OPTIONS /Townsend
      server  L1_1 10.211.55.1:7003  check
      server  L1_2 10.211.55.2:7004  check
   server  L1_3 10.211.55.3:7004  check
      appsession JSESSIONID len 52 timeout 3h

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

满地尘埃落定 2024-08-13 08:21:53

然后,如果哪个服务器处理请求并不重要,请禁用粘性并删除 appsession 行。您必须了解粘性与负载平衡相反。如果您的问题是无法扩展,请先不要坚持。

Then if it does not matter which server serves the request, disable stickiness and remove the appsession line. You must understand that stickiness is the opposite of load-balancing. If your issue is that you don't scale, don't stick first.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文