春季云网关/负载保龄球员是否可以保持连接的活力?

发布于 2025-01-22 02:29:09 字数 2713 浏览 0 评论 0原文

我已经用whoami服务设置了一个复制20次的docker群。当我做wget -qo -whoamiwget -qo -qo -qo -qo -10.0.xx ip地址时,我从网关容器中进行wget -qo -qo -qo -qo-但是,当我在弹簧云网关上做类似的事情时,它会不断击中相同的副本。

在弹簧云网关或负载平衡器中是否有一些使连接粘在同一节点中的东西?

同样可以禁用,因此我可以测试Round Robin

Bom是set('SpringCloudversion',“ 2021.0.1”)

application.yml的相关块。没有发现只是一条简单的路线。

spring:
  cloud:
    gateway:
      routes:
        - id: after_route
          uri: http://whoami2
          predicates:
            - Path=/who

产生以下输出较大的输出

 spring-docker   rework [!⇡] via ☕ v17.32 
❯ curl  http://localhost:28080/who
Hostname: cef30a15e0e8
IP: 127.0.0.1
IP: 10.0.3.233
IP: 172.18.0.6
RemoteAddr: 10.0.3.22:54676
GET /who HTTP/1.1
Host: whoami2
User-Agent: curl/7.79.1
Accept: */*
Forwarded: proto=http;host="localhost:28080";for="10.0.0.2:36624"
X-B3-Parentspanid: 264246902b820058
X-B3-Sampled: 1
X-B3-Spanid: 2727f63f28f4f775
X-B3-Traceid: 264246902b820058
X-Forwarded-For: 10.0.0.2
X-Forwarded-Host: localhost:28080
X-Forwarded-Port: 28080
X-Forwarded-Proto: http


 spring-docker   rework [!⇡] via ☕ v17.32 
❯ curl  http://localhost:28080/who
Hostname: cef30a15e0e8
IP: 127.0.0.1
IP: 10.0.3.233
IP: 172.18.0.6
RemoteAddr: 10.0.3.22:54676
GET /who HTTP/1.1
Host: whoami2
User-Agent: curl/7.79.1
Accept: */*
Forwarded: proto=http;host="localhost:28080";for="10.0.0.2:36626"
X-B3-Parentspanid: 37f7bcc012a2f20e
X-B3-Sampled: 1
X-B3-Spanid: 9a39133b80384588
X-B3-Traceid: 37f7bcc012a2f20e
X-Forwarded-For: 10.0.0.2
X-Forwarded-Host: localhost:28080
X-Forwarded-Port: 28080
X-Forwarded-Proto: http

通过发现

spring:
  cache:
    type: redis
  cloud:
    gateway:
#      fail-on-route-definition-error: false
      routes: []
      discovery:
        locator:
          enabled: true
          url-expression: "uri"
          predicates:
            - name: Path
              args:
                patterns: "metadata['path']"
          filters:
            - RemoveRequestHeader='Cookie'
            - RemoveRequestHeader='X-B3-TraceId'
            - name: Retry
              args:
                retries: 3
              methods:
                - GET
            - name: RewritePath
              args:
                regexp: "metadata['path.regexp']"
                replacement: "metadata['path.replacement']"
#    inetutils:
#      ignoredInterfaces:
#        - docker0
#        - veth.*
#        - eth3
#    loadbalancer:
##      enabled: false
#      ribbon:
#        enabled: false
#      cache:
#        enabled: false

I have set up a Docker Swarm with the whoami service that is replicated 20 times. From the gateway container when I do wget -qO - whoami or the wget -qO - 10.0.x.x IP address I get random whoami replicas. However, when I do a similar thing on Spring Cloud Gateway it keeps on hitting the same replica.

Is there something in Spring Cloud Gateway or Load Balancer that keeps the connection stuck to the same node?

Also is it possible to disable that so I can test round robin

BOM is set('springCloudVersion', "2021.0.1")

Relevant blocks of application.yml. No discovery just a simple route.

spring:
  cloud:
    gateway:
      routes:
        - id: after_route
          uri: http://whoami2
          predicates:
            - Path=/who

Yields the following output

 spring-docker   rework [!⇡] via ☕ v17.32 
❯ curl  http://localhost:28080/who
Hostname: cef30a15e0e8
IP: 127.0.0.1
IP: 10.0.3.233
IP: 172.18.0.6
RemoteAddr: 10.0.3.22:54676
GET /who HTTP/1.1
Host: whoami2
User-Agent: curl/7.79.1
Accept: */*
Forwarded: proto=http;host="localhost:28080";for="10.0.0.2:36624"
X-B3-Parentspanid: 264246902b820058
X-B3-Sampled: 1
X-B3-Spanid: 2727f63f28f4f775
X-B3-Traceid: 264246902b820058
X-Forwarded-For: 10.0.0.2
X-Forwarded-Host: localhost:28080
X-Forwarded-Port: 28080
X-Forwarded-Proto: http


 spring-docker   rework [!⇡] via ☕ v17.32 
❯ curl  http://localhost:28080/who
Hostname: cef30a15e0e8
IP: 127.0.0.1
IP: 10.0.3.233
IP: 172.18.0.6
RemoteAddr: 10.0.3.22:54676
GET /who HTTP/1.1
Host: whoami2
User-Agent: curl/7.79.1
Accept: */*
Forwarded: proto=http;host="localhost:28080";for="10.0.0.2:36626"
X-B3-Parentspanid: 37f7bcc012a2f20e
X-B3-Sampled: 1
X-B3-Spanid: 9a39133b80384588
X-B3-Traceid: 37f7bcc012a2f20e
X-Forwarded-For: 10.0.0.2
X-Forwarded-Host: localhost:28080
X-Forwarded-Port: 28080
X-Forwarded-Proto: http

Older with the discovery

spring:
  cache:
    type: redis
  cloud:
    gateway:
#      fail-on-route-definition-error: false
      routes: []
      discovery:
        locator:
          enabled: true
          url-expression: "uri"
          predicates:
            - name: Path
              args:
                patterns: "metadata['path']"
          filters:
            - RemoveRequestHeader='Cookie'
            - RemoveRequestHeader='X-B3-TraceId'
            - name: Retry
              args:
                retries: 3
              methods:
                - GET
            - name: RewritePath
              args:
                regexp: "metadata['path.regexp']"
                replacement: "metadata['path.replacement']"
#    inetutils:
#      ignoredInterfaces:
#        - docker0
#        - veth.*
#        - eth3
#    loadbalancer:
##      enabled: false
#      ribbon:
#        enabled: false
#      cache:
#        enabled: false

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文