找回密码
 立即注册
首页 业界区 安全 wso2~分布式集群部署总结

wso2~分布式集群部署总结

萨瑞饨 9 小时前
集群模式需要有关注这块,如果是all-in-one模式,你部署多个节点,这不叫集群模式,它会有多种状态信息不一致,会有多种问题,如果希望将网关tw,平台acp(admin,consumer,publisher),密钥管理km,限流管理tm分开部署多份,需要使用Distributed Deployment 模式(https://apim.docs.wso2.com/en/latest/install-and-setup/setup/kubernetes-deployment/kubernetes/am-pattern-3-acp-tm-gw/)。

  • https://www.yenlo.com/blogs/custom-rate-limiting-with-wso2-apim/
  • https://apim.docs.wso2.com/en/4.1.0/design/rate-limiting/advanced-topics/configuring-rate-limiting-api-gateway-cluster/
  • https://apim.docs.wso2.com/en/latest/manage-apis/design/rate-limiting/advanced-topics/configuring-rate-limiting-api-gateway-cluster/
  • https://github.com/wso2/api-manager/issues/3961
  • https://github.com/wso2/api-manager/issues/359
helm-distribute分布式部署

部署顺序


  • control-plane
  • gateway
  • traffic-manager
  • key-manager[未在私有仓库找到景象,目前它集成到control-plane里]
各子服务Dockerfile添加jdbc
  1. FROM wso2/wso2am-tm:4.5.0
  2. ARG USER=wso2carbon
  3. ARG USER_HOME=/home/${USER}
  4. ARG WSO2_SERVER_NAME=wso2am-tm
  5. ARG WSO2_SERVER_VERSION=4.5.0
  6. ARG WSO2_SERVER=${WSO2_SERVER_NAME}-${WSO2_SERVER_VERSION}
  7. ARG WSO2_SERVER_HOME=${USER_HOME}/${WSO2_SERVER}
  8. # Copy JDBC MySQL driver
  9. ADD --chown=wso2carbon:wso2 https://repo1.maven.org/maven2/mysql/mysql-connector-java/8.0.28/mysql-connector-java-8.0.28.jar ${WSO2_SERVER_HOME}/repository/components/lib
复制代码
gateway中配置acp的服务名和实例名
  1. wso2:
  2. apim:
  3.    configurations
  4.       throttling:
  5.         # -- Traffic manager loadbalancer service url for throttling.
  6.         # If the traffic manager is separated from control-plane, all urls should be pointed to traffic-manager ones.
  7.         serviceUrl: "wso2am-acp-service" # 对应control-plane的主服务名
  8.       eventhub:
  9.         # -- Event hub (control plane) enabled.
  10.         # This should be enabled if the traffic manager is separated from the control-plane.
  11.         enabled: false
  12.         # -- Event hub (control plane) loadbalancer service url
  13.         serviceUrl: "wso2am-acp-service"
复制代码
多节点集群


  • cp(control-plane) 支持多副本,多个deployment
  • gateway 无状态,直接使用deployment多副本功能
  • traffic-manager 支持多副本,多个deployment
1.jpeg

redis throttle相关

相关动态

Update 02/07/2025

  • Until now, Redis was only tested in an all-in-one deployment. Since the actual requirement is to support a multi-Traffic Manager (TM) node deployment, set up a distributed APIM deployment—with support from @kavindasr —consisting of 2 ACP nodes, 2 GW nodes, 2 TM nodes, and a Redis Cluster hosted in AWS.
  • To support the Redis Cluster, I refactored the implementation to use JedisCluster instead of JedisPooled, and verified the functionality in this distributed setup.
  • Initially, a configuration mismatch caused the Redis count to be incremented multiple times per API request—once by each Traffic Manager. After identifying the issue, adjusted the configuration to ensure correct and consistent counter updates.
redis配置

/deployment.toml
  1. [apim.redis_config]
  2. host = "localhost"
  3. port = "6379"
  4. gateway_id="my_gateway_1234"
  5. [throttle_properties]
  6. 'throttling.distributed.counter.type' = "redis"
  7. 'throttling.sync-async_hybrid_mode.enable' = true
  8. 'throttling.local_quota_buffer_percentage' = 30
复制代码
限流throttling的redis的pub/sub

通过使用redis的pub/sub功能,对某个频道wso2_sync_mode_init_channel进行订阅,订阅中会统计数量
查看当前活跃的频道
  1. C:\Users\User>redis-cli PUBSUB CHANNELS
  2. 1) "wso2_sync_mode_init_channel"
复制代码
查看某个频道订阅的数量
  1. C:\Users\User>redis-cli PUBSUB NUMSUB  wso2_sync_mode_init_channel
  2. 1) "wso2_sync_mode_init_channel"
  3. 2) (integer) 1
复制代码
来源:程序园用户自行投稿发布,如果侵权,请联系站长删除
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!
您需要登录后才可以回帖 登录 | 立即注册