Spring Cloud Gateway 网关压测
公司的API网关出现了重启
- 确认业务层面有无促销等场景造成的流量暴增 无
- 确认程序上有无疯狂刷接口的行为  无
- 确认流量分配是否均衡 无
- 确认最近有无上线行为 无
以上排查都无果
压测场景:
- 写一个超时接口,超时时间40s,大于网关全局超时,模拟连接被hold的场景
- 压测监控检测接口。因为k8s健康监测功能,会监测这个接口来判定服务是否健康。不健康则会重启pod
使用Jmeter来压测网关。使用6000个的线程来并发压测网关,可以复现
修改配置,新增绿色部分
spring:  cloud:    discovery:
      client:        health-indicator:          enabled: false    gateway:      httpclient:        connect-timeout: 2000
        response-timeout: 30s        response-timeout: 6s
        pool:          max-idle-time: PT10S #线程最大空闲时间,超时回收          eviction-interval: PT30S  #定期回收频率      routes:        - id: moatkon          uri: lb://moatkon-service          predicates:            - Path=/moatkon/**
          metadata:            connect-timeout: 5000            response-timeout: 30000
management:
  endpoint:    health:      enabled: true      show-details: always
  health:    defaults:      enabled: false  endpoints:    web:      exposure:        include: ["*"]在启动应用时添加JVM参数:
-Dreactor.netty.pool.leasingStrategy=lifo结果显示,6000并发持续压测3h+无重启现象